Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

CDVFile.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. */
  17. #import <Foundation/Foundation.h>
  18. #import <Cordova/CDVPlugin.h>
  19. extern NSString* const kCDVAssetsLibraryPrefix;
  20. extern NSString* const kCDVFilesystemURLPrefix;
  21. enum CDVFileError {
  22. NO_ERROR = 0,
  23. NOT_FOUND_ERR = 1,
  24. SECURITY_ERR = 2,
  25. ABORT_ERR = 3,
  26. NOT_READABLE_ERR = 4,
  27. ENCODING_ERR = 5,
  28. NO_MODIFICATION_ALLOWED_ERR = 6,
  29. INVALID_STATE_ERR = 7,
  30. SYNTAX_ERR = 8,
  31. INVALID_MODIFICATION_ERR = 9,
  32. QUOTA_EXCEEDED_ERR = 10,
  33. TYPE_MISMATCH_ERR = 11,
  34. PATH_EXISTS_ERR = 12
  35. };
  36. typedef int CDVFileError;
  37. @interface CDVFilesystemURL : NSObject {
  38. NSURL *_url;
  39. NSString *_fileSystemName;
  40. NSString *_fullPath;
  41. }
  42. - (id) initWithString:(NSString*)strURL;
  43. - (id) initWithURL:(NSURL*)URL;
  44. + (CDVFilesystemURL *)fileSystemURLWithString:(NSString *)strURL;
  45. + (CDVFilesystemURL *)fileSystemURLWithURL:(NSURL *)URL;
  46. - (NSString *)absoluteURL;
  47. @property (atomic) NSURL *url;
  48. @property (atomic) NSString *fileSystemName;
  49. @property (atomic) NSString *fullPath;
  50. @end
  51. @interface CDVFilesystemURLProtocol : NSURLProtocol
  52. @end
  53. @protocol CDVFileSystem
  54. - (CDVPluginResult *)entryForLocalURI:(CDVFilesystemURL *)url;
  55. - (CDVPluginResult *)getFileForURL:(CDVFilesystemURL *)baseURI requestedPath:(NSString *)requestedPath options:(NSDictionary *)options;
  56. - (CDVPluginResult *)getParentForURL:(CDVFilesystemURL *)localURI;
  57. - (CDVPluginResult *)setMetadataForURL:(CDVFilesystemURL *)localURI withObject:(NSDictionary *)options;
  58. - (CDVPluginResult *)removeFileAtURL:(CDVFilesystemURL *)localURI;
  59. - (CDVPluginResult *)recursiveRemoveFileAtURL:(CDVFilesystemURL *)localURI;
  60. - (CDVPluginResult *)readEntriesAtURL:(CDVFilesystemURL *)localURI;
  61. - (CDVPluginResult *)truncateFileAtURL:(CDVFilesystemURL *)localURI atPosition:(unsigned long long)pos;
  62. - (CDVPluginResult *)writeToFileAtURL:(CDVFilesystemURL *)localURL withData:(NSData*)encData append:(BOOL)shouldAppend;
  63. - (void)copyFileToURL:(CDVFilesystemURL *)destURL withName:(NSString *)newName fromFileSystem:(NSObject<CDVFileSystem> *)srcFs atURL:(CDVFilesystemURL *)srcURL copy:(BOOL)bCopy callback:(void (^)(CDVPluginResult *))callback;
  64. - (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback;
  65. - (void)getFileMetadataForURL:(CDVFilesystemURL *)localURL callback:(void (^)(CDVPluginResult *))callback;
  66. - (NSDictionary *)makeEntryForLocalURL:(CDVFilesystemURL *)url;
  67. - (NSDictionary*)makeEntryForPath:(NSString*)fullPath isDirectory:(BOOL)isDir;
  68. @property (nonatomic,strong) NSString *name;
  69. @property (nonatomic, copy) NSURL*(^urlTransformer)(NSURL*);
  70. @optional
  71. - (NSString *)filesystemPathForURL:(CDVFilesystemURL *)localURI;
  72. - (CDVFilesystemURL *)URLforFilesystemPath:(NSString *)path;
  73. @end
  74. @interface CDVFile : CDVPlugin {
  75. NSString* rootDocsPath;
  76. NSString* appDocsPath;
  77. NSString* appLibraryPath;
  78. NSString* appTempPath;
  79. NSMutableArray* fileSystems_;
  80. BOOL userHasAllowed;
  81. }
  82. - (NSNumber*)checkFreeDiskSpace:(NSString*)appPath;
  83. - (NSDictionary*)makeEntryForPath:(NSString*)fullPath fileSystemName:(NSString *)fsName isDirectory:(BOOL)isDir;
  84. - (NSDictionary *)makeEntryForURL:(NSURL *)URL;
  85. - (CDVFilesystemURL *)fileSystemURLforLocalPath:(NSString *)localPath;
  86. - (NSObject<CDVFileSystem> *)filesystemForURL:(CDVFilesystemURL *)localURL;
  87. /* Native Registration API */
  88. - (void)registerFilesystem:(NSObject<CDVFileSystem> *)fs;
  89. - (NSObject<CDVFileSystem> *)fileSystemByName:(NSString *)fsName;
  90. /* Exec API */
  91. - (void)requestFileSystem:(CDVInvokedUrlCommand*)command;
  92. - (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command;
  93. - (void)getDirectory:(CDVInvokedUrlCommand*)command;
  94. - (void)getFile:(CDVInvokedUrlCommand*)command;
  95. - (void)getParent:(CDVInvokedUrlCommand*)command;
  96. - (void)removeRecursively:(CDVInvokedUrlCommand*)command;
  97. - (void)remove:(CDVInvokedUrlCommand*)command;
  98. - (void)copyTo:(CDVInvokedUrlCommand*)command;
  99. - (void)moveTo:(CDVInvokedUrlCommand*)command;
  100. - (void)getFileMetadata:(CDVInvokedUrlCommand*)command;
  101. - (void)readEntries:(CDVInvokedUrlCommand*)command;
  102. - (void)readAsText:(CDVInvokedUrlCommand*)command;
  103. - (void)readAsDataURL:(CDVInvokedUrlCommand*)command;
  104. - (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command;
  105. - (void)write:(CDVInvokedUrlCommand*)command;
  106. - (void)testFileExists:(CDVInvokedUrlCommand*)command;
  107. - (void)testDirectoryExists:(CDVInvokedUrlCommand*)command;
  108. - (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command;
  109. - (void)truncate:(CDVInvokedUrlCommand*)command;
  110. - (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy;
  111. /* Compatibilty with older File API */
  112. - (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
  113. - (NSDictionary *)getDirectoryEntry:(NSString *)target isDirectory:(BOOL)bDirRequest;
  114. /* Conversion between filesystem paths and URLs */
  115. - (NSString *)filesystemPathForURL:(CDVFilesystemURL *)URL;
  116. /* Internal methods for testing */
  117. - (void)_getLocalFilesystemPath:(CDVInvokedUrlCommand*)command;
  118. @property (nonatomic, strong) NSString* rootDocsPath;
  119. @property (nonatomic, strong) NSString* appDocsPath;
  120. @property (nonatomic, strong) NSString* appLibraryPath;
  121. @property (nonatomic, strong) NSString* appTempPath;
  122. @property (nonatomic, strong) NSString* persistentPath;
  123. @property (nonatomic, strong) NSString* temporaryPath;
  124. @property (nonatomic, strong) NSMutableArray* fileSystems;
  125. @property BOOL userHasAllowed;
  126. @end
  127. #define kW3FileTemporary @"temporary"
  128. #define kW3FilePersistent @"persistent"