Path: blob/trunk/third_party/closure/goog/fs/entry.js
2868 views
// Copyright 2011 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Wrappers for HTML5 Entry objects. These are all in the same16* file to avoid circular dependency issues.17*18* When adding or modifying functionality in this namespace, be sure to update19* the mock counterparts in goog.testing.fs.20*21*/22goog.provide('goog.fs.DirectoryEntry');23goog.provide('goog.fs.DirectoryEntry.Behavior');24goog.provide('goog.fs.Entry');25goog.provide('goog.fs.FileEntry');26272829/**30* The interface for entries in the filesystem.31* @interface32*/33goog.fs.Entry = function() {};343536/**37* @return {boolean} Whether or not this entry is a file.38*/39goog.fs.Entry.prototype.isFile = function() {};404142/**43* @return {boolean} Whether or not this entry is a directory.44*/45goog.fs.Entry.prototype.isDirectory = function() {};464748/**49* @return {string} The name of this entry.50*/51goog.fs.Entry.prototype.getName = function() {};525354/**55* @return {string} The full path to this entry.56*/57goog.fs.Entry.prototype.getFullPath = function() {};585960/**61* @return {!goog.fs.FileSystem} The filesystem backing this entry.62*/63goog.fs.Entry.prototype.getFileSystem = function() {};646566/**67* Retrieves the last modified date for this entry.68*69* @return {!goog.async.Deferred} The deferred Date for this entry. If an error70* occurs, the errback is called with a {@link goog.fs.Error}.71*/72goog.fs.Entry.prototype.getLastModified = function() {};737475/**76* Retrieves the metadata for this entry.77*78* @return {!goog.async.Deferred} The deferred Metadata for this entry. If an79* error occurs, the errback is called with a {@link goog.fs.Error}.80*/81goog.fs.Entry.prototype.getMetadata = function() {};828384/**85* Move this entry to a new location.86*87* @param {!goog.fs.DirectoryEntry} parent The new parent directory.88* @param {string=} opt_newName The new name of the entry. If omitted, the entry89* retains its original name.90* @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry} or91* {@link goog.fs.DirectoryEntry} for the new entry. If an error occurs, the92* errback is called with a {@link goog.fs.Error}.93*/94goog.fs.Entry.prototype.moveTo = function(parent, opt_newName) {};959697/**98* Copy this entry to a new location.99*100* @param {!goog.fs.DirectoryEntry} parent The new parent directory.101* @param {string=} opt_newName The name of the new entry. If omitted, the new102* entry has the same name as the original.103* @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry} or104* {@link goog.fs.DirectoryEntry} for the new entry. If an error occurs, the105* errback is called with a {@link goog.fs.Error}.106*/107goog.fs.Entry.prototype.copyTo = function(parent, opt_newName) {};108109110/**111* Wrap an HTML5 entry object in an appropriate subclass instance.112*113* @param {!Entry} entry The underlying Entry object.114* @return {!goog.fs.Entry} The appropriate subclass wrapper.115* @protected116*/117goog.fs.Entry.prototype.wrapEntry = function(entry) {};118119120/**121* Get the URL for this file.122*123* @param {string=} opt_mimeType The MIME type that will be served for the URL.124* @return {string} The URL.125*/126goog.fs.Entry.prototype.toUrl = function(opt_mimeType) {};127128129/**130* Get the URI for this file.131*132* @deprecated Use {@link #toUrl} instead.133* @param {string=} opt_mimeType The MIME type that will be served for the URI.134* @return {string} The URI.135*/136goog.fs.Entry.prototype.toUri = function(opt_mimeType) {};137138139/**140* Remove this entry.141*142* @return {!goog.async.Deferred} A deferred object. If the removal succeeds,143* the callback is called with true. If an error occurs, the errback is144* called a {@link goog.fs.Error}.145*/146goog.fs.Entry.prototype.remove = function() {};147148149/**150* Gets the parent directory.151*152* @return {!goog.async.Deferred} The deferred {@link goog.fs.DirectoryEntry}.153* If an error occurs, the errback is called with a {@link goog.fs.Error}.154*/155goog.fs.Entry.prototype.getParent = function() {};156157158159/**160* A directory in a local FileSystem.161*162* @interface163* @extends {goog.fs.Entry}164*/165goog.fs.DirectoryEntry = function() {};166167168/**169* Behaviors for getting files and directories.170* @enum {number}171*/172goog.fs.DirectoryEntry.Behavior = {173/**174* Get the file if it exists, error out if it doesn't.175*/176DEFAULT: 1,177/**178* Get the file if it exists, create it if it doesn't.179*/180CREATE: 2,181/**182* Error out if the file exists, create it if it doesn't.183*/184CREATE_EXCLUSIVE: 3185};186187188/**189* Get a file in the directory.190*191* @param {string} path The path to the file, relative to this directory.192* @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for193* handling an existing file, or the lack thereof.194* @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry}. If an195* error occurs, the errback is called with a {@link goog.fs.Error}.196*/197goog.fs.DirectoryEntry.prototype.getFile = function(path, opt_behavior) {};198199200/**201* Get a directory within this directory.202*203* @param {string} path The path to the directory, relative to this directory.204* @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for205* handling an existing directory, or the lack thereof.206* @return {!goog.async.Deferred} The deferred {@link goog.fs.DirectoryEntry}.207* If an error occurs, the errback is called a {@link goog.fs.Error}.208*/209goog.fs.DirectoryEntry.prototype.getDirectory = function(path, opt_behavior) {};210211212/**213* Opens the directory for the specified path, creating the directory and any214* intermediate directories as necessary.215*216* @param {string} path The directory path to create. May be absolute or217* relative to the current directory. The parent directory ".." and current218* directory "." are supported.219* @return {!goog.async.Deferred} A deferred {@link goog.fs.DirectoryEntry} for220* the requested path. If an error occurs, the errback is called with a221* {@link goog.fs.Error}.222*/223goog.fs.DirectoryEntry.prototype.createPath = function(path) {};224225226/**227* Gets a list of all entries in this directory.228*229* @return {!goog.async.Deferred} The deferred list of {@link goog.fs.Entry}230* results. If an error occurs, the errback is called with a231* {@link goog.fs.Error}.232*/233goog.fs.DirectoryEntry.prototype.listDirectory = function() {};234235236/**237* Removes this directory and all its contents.238*239* @return {!goog.async.Deferred} A deferred object. If the removal succeeds,240* the callback is called with true. If an error occurs, the errback is241* called a {@link goog.fs.Error}.242*/243goog.fs.DirectoryEntry.prototype.removeRecursively = function() {};244245246247/**248* A file in a local filesystem.249*250* @interface251* @extends {goog.fs.Entry}252*/253goog.fs.FileEntry = function() {};254255256/**257* Create a writer for writing to the file.258*259* @return {!goog.async.Deferred<!goog.fs.FileWriter>} If an error occurs, the260* errback is called with a {@link goog.fs.Error}.261*/262goog.fs.FileEntry.prototype.createWriter = function() {};263264265/**266* Get the file contents as a File blob.267*268* @return {!goog.async.Deferred<!File>} If an error occurs, the errback is269* called with a {@link goog.fs.Error}.270*/271goog.fs.FileEntry.prototype.file = function() {};272273274