entry.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. // Copyright 2011 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Wrappers for HTML5 Entry objects. These are all in the same
  16. * file to avoid circular dependency issues.
  17. *
  18. * When adding or modifying functionality in this namespace, be sure to update
  19. * the mock counterparts in goog.testing.fs.
  20. *
  21. */
  22. goog.provide('goog.fs.DirectoryEntry');
  23. goog.provide('goog.fs.DirectoryEntry.Behavior');
  24. goog.provide('goog.fs.Entry');
  25. goog.provide('goog.fs.FileEntry');
  26. /**
  27. * The interface for entries in the filesystem.
  28. * @interface
  29. */
  30. goog.fs.Entry = function() {};
  31. /**
  32. * @return {boolean} Whether or not this entry is a file.
  33. */
  34. goog.fs.Entry.prototype.isFile = function() {};
  35. /**
  36. * @return {boolean} Whether or not this entry is a directory.
  37. */
  38. goog.fs.Entry.prototype.isDirectory = function() {};
  39. /**
  40. * @return {string} The name of this entry.
  41. */
  42. goog.fs.Entry.prototype.getName = function() {};
  43. /**
  44. * @return {string} The full path to this entry.
  45. */
  46. goog.fs.Entry.prototype.getFullPath = function() {};
  47. /**
  48. * @return {!goog.fs.FileSystem} The filesystem backing this entry.
  49. */
  50. goog.fs.Entry.prototype.getFileSystem = function() {};
  51. /**
  52. * Retrieves the last modified date for this entry.
  53. *
  54. * @return {!goog.async.Deferred} The deferred Date for this entry. If an error
  55. * occurs, the errback is called with a {@link goog.fs.Error}.
  56. */
  57. goog.fs.Entry.prototype.getLastModified = function() {};
  58. /**
  59. * Retrieves the metadata for this entry.
  60. *
  61. * @return {!goog.async.Deferred} The deferred Metadata for this entry. If an
  62. * error occurs, the errback is called with a {@link goog.fs.Error}.
  63. */
  64. goog.fs.Entry.prototype.getMetadata = function() {};
  65. /**
  66. * Move this entry to a new location.
  67. *
  68. * @param {!goog.fs.DirectoryEntry} parent The new parent directory.
  69. * @param {string=} opt_newName The new name of the entry. If omitted, the entry
  70. * retains its original name.
  71. * @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry} or
  72. * {@link goog.fs.DirectoryEntry} for the new entry. If an error occurs, the
  73. * errback is called with a {@link goog.fs.Error}.
  74. */
  75. goog.fs.Entry.prototype.moveTo = function(parent, opt_newName) {};
  76. /**
  77. * Copy this entry to a new location.
  78. *
  79. * @param {!goog.fs.DirectoryEntry} parent The new parent directory.
  80. * @param {string=} opt_newName The name of the new entry. If omitted, the new
  81. * entry has the same name as the original.
  82. * @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry} or
  83. * {@link goog.fs.DirectoryEntry} for the new entry. If an error occurs, the
  84. * errback is called with a {@link goog.fs.Error}.
  85. */
  86. goog.fs.Entry.prototype.copyTo = function(parent, opt_newName) {};
  87. /**
  88. * Wrap an HTML5 entry object in an appropriate subclass instance.
  89. *
  90. * @param {!Entry} entry The underlying Entry object.
  91. * @return {!goog.fs.Entry} The appropriate subclass wrapper.
  92. * @protected
  93. */
  94. goog.fs.Entry.prototype.wrapEntry = function(entry) {};
  95. /**
  96. * Get the URL for this file.
  97. *
  98. * @param {string=} opt_mimeType The MIME type that will be served for the URL.
  99. * @return {string} The URL.
  100. */
  101. goog.fs.Entry.prototype.toUrl = function(opt_mimeType) {};
  102. /**
  103. * Get the URI for this file.
  104. *
  105. * @deprecated Use {@link #toUrl} instead.
  106. * @param {string=} opt_mimeType The MIME type that will be served for the URI.
  107. * @return {string} The URI.
  108. */
  109. goog.fs.Entry.prototype.toUri = function(opt_mimeType) {};
  110. /**
  111. * Remove this entry.
  112. *
  113. * @return {!goog.async.Deferred} A deferred object. If the removal succeeds,
  114. * the callback is called with true. If an error occurs, the errback is
  115. * called a {@link goog.fs.Error}.
  116. */
  117. goog.fs.Entry.prototype.remove = function() {};
  118. /**
  119. * Gets the parent directory.
  120. *
  121. * @return {!goog.async.Deferred} The deferred {@link goog.fs.DirectoryEntry}.
  122. * If an error occurs, the errback is called with a {@link goog.fs.Error}.
  123. */
  124. goog.fs.Entry.prototype.getParent = function() {};
  125. /**
  126. * A directory in a local FileSystem.
  127. *
  128. * @interface
  129. * @extends {goog.fs.Entry}
  130. */
  131. goog.fs.DirectoryEntry = function() {};
  132. /**
  133. * Behaviors for getting files and directories.
  134. * @enum {number}
  135. */
  136. goog.fs.DirectoryEntry.Behavior = {
  137. /**
  138. * Get the file if it exists, error out if it doesn't.
  139. */
  140. DEFAULT: 1,
  141. /**
  142. * Get the file if it exists, create it if it doesn't.
  143. */
  144. CREATE: 2,
  145. /**
  146. * Error out if the file exists, create it if it doesn't.
  147. */
  148. CREATE_EXCLUSIVE: 3
  149. };
  150. /**
  151. * Get a file in the directory.
  152. *
  153. * @param {string} path The path to the file, relative to this directory.
  154. * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for
  155. * handling an existing file, or the lack thereof.
  156. * @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry}. If an
  157. * error occurs, the errback is called with a {@link goog.fs.Error}.
  158. */
  159. goog.fs.DirectoryEntry.prototype.getFile = function(path, opt_behavior) {};
  160. /**
  161. * Get a directory within this directory.
  162. *
  163. * @param {string} path The path to the directory, relative to this directory.
  164. * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for
  165. * handling an existing directory, or the lack thereof.
  166. * @return {!goog.async.Deferred} The deferred {@link goog.fs.DirectoryEntry}.
  167. * If an error occurs, the errback is called a {@link goog.fs.Error}.
  168. */
  169. goog.fs.DirectoryEntry.prototype.getDirectory = function(path, opt_behavior) {};
  170. /**
  171. * Opens the directory for the specified path, creating the directory and any
  172. * intermediate directories as necessary.
  173. *
  174. * @param {string} path The directory path to create. May be absolute or
  175. * relative to the current directory. The parent directory ".." and current
  176. * directory "." are supported.
  177. * @return {!goog.async.Deferred} A deferred {@link goog.fs.DirectoryEntry} for
  178. * the requested path. If an error occurs, the errback is called with a
  179. * {@link goog.fs.Error}.
  180. */
  181. goog.fs.DirectoryEntry.prototype.createPath = function(path) {};
  182. /**
  183. * Gets a list of all entries in this directory.
  184. *
  185. * @return {!goog.async.Deferred} The deferred list of {@link goog.fs.Entry}
  186. * results. If an error occurs, the errback is called with a
  187. * {@link goog.fs.Error}.
  188. */
  189. goog.fs.DirectoryEntry.prototype.listDirectory = function() {};
  190. /**
  191. * Removes this directory and all its contents.
  192. *
  193. * @return {!goog.async.Deferred} A deferred object. If the removal succeeds,
  194. * the callback is called with true. If an error occurs, the errback is
  195. * called a {@link goog.fs.Error}.
  196. */
  197. goog.fs.DirectoryEntry.prototype.removeRecursively = function() {};
  198. /**
  199. * A file in a local filesystem.
  200. *
  201. * @interface
  202. * @extends {goog.fs.Entry}
  203. */
  204. goog.fs.FileEntry = function() {};
  205. /**
  206. * Create a writer for writing to the file.
  207. *
  208. * @return {!goog.async.Deferred<!goog.fs.FileWriter>} If an error occurs, the
  209. * errback is called with a {@link goog.fs.Error}.
  210. */
  211. goog.fs.FileEntry.prototype.createWriter = function() {};
  212. /**
  213. * Get the file contents as a File blob.
  214. *
  215. * @return {!goog.async.Deferred<!File>} If an error occurs, the errback is
  216. * called with a {@link goog.fs.Error}.
  217. */
  218. goog.fs.FileEntry.prototype.file = function() {};