Inheritance diagram for pp::FileRef:

List of all members.

Public Member Functions

 FileRef ()
 FileRef (PP_Resource resource)
 FileRef (PassRef, PP_Resource resource)
 FileRef (const FileSystem &file_system, const char *path)
 FileRef (const FileRef &other)
PP_FileSystemType GetFileSystemType () const
Var GetName () const
Var GetPath () const
FileRef GetParent () const
int32_t MakeDirectory (int32_t make_directory_flags, const CompletionCallback &cc)
int32_t Touch (PP_Time last_access_time, PP_Time last_modified_time, const CompletionCallback &cc)
int32_t Delete (const CompletionCallback &cc)
int32_t Rename (const FileRef &new_file_ref, const CompletionCallback &cc)
int32_t Query (const CompletionCallbackWithOutput< PP_FileInfo > &callback)
int32_t ReadDirectoryEntries (const CompletionCallbackWithOutput< std::vector< DirectoryEntry > > &callback)

Detailed Description

The FileRef class represents a "weak pointer" to a file in a file system.


Constructor & Destructor Documentation

Default constructor for creating an is_null() FileRef object.

pp::FileRef::FileRef(PP_Resource resource) [explicit]

A constructor used when you have an existing PP_Resource for a FileRef and which to create a C++ object that takes an additional reference to the resource.

Parameters:
[in]resourceA PP_Resource corresponding to file reference.
pp::FileRef::FileRef(PassRef ,
PP_Resource resource 
)

A constructor used when you have received a PP_Resource as a return value that has already been reference counted.

Parameters:
[in]resourceA PP_Resource corresponding to file reference.
pp::FileRef::FileRef(const FileSystemfile_system,
const char * path 
)

A constructor that creates a weak pointer to a file in the given file system.

File paths are POSIX style.

If the path is malformed, the resulting FileRef will have a null PP_Resource.

Parameters:
[in]file_systemA FileSystem corresponding to a file system type.
[in]pathA path to the file. Must begin with a '/' character.

The copy constructor for FileRef.

Parameters:
[in]otherA pointer to a FileRef.

Member Function Documentation

Delete() deletes a file or directory.

If file_ref refers to a directory, then the directory must be empty. It is an error to delete a file or directory that is in use. It is not valid to delete a file in the external file system.

Parameters:
[in]ccA CompletionCallback to be called upon completion of Delete().
Returns:
An int32_t containing an error code from pp_errors.h.
PP_FileSystemType pp::FileRef::GetFileSystemType()const

GetFileSystemType() returns the type of the file system.

Returns:
A PP_FileSystemType with the file system type if valid or PP_FILESYSTEMTYPE_INVALID if the provided resource is not a valid file reference.

GetName() returns the name of the file.

Returns:
A Var containing the name of the file. The value returned by this function does not include any path components (such as the name of the parent directory, for example). It is just the name of the file. Use GetPath() to get the full file path.

GetParent() returns the parent directory of this file.

If file_ref points to the root of the filesystem, then the root is returned.

Returns:
A FileRef containing the parent directory of the file. This function fails if the file system type is PP_FileSystemType_External.

GetPath() returns the absolute path of the file.

Returns:
A Var containing the absolute path of the file. This function fails if the file system type is PP_FileSystemType_External.
int32_t pp::FileRef::MakeDirectory(int32_t make_directory_flags,
const CompletionCallbackcc 
)

MakeDirectory() makes a new directory in the file system according to the given make_directory_flags, which is a bit-mask of the PP_MakeDirectoryFlags values.

It is not valid to make a directory in the external file system.

Parameters:
[in]make_directory_flagsA bit-mask of the PP_MakeDirectoryFlags values. See ppb_file_ref.h for more details.
[in]ccA CompletionCallback to be called upon completion of MakeDirectory().
Returns:
An int32_t containing an error code from pp_errors.h.
int32_t pp::FileRef::Query(const CompletionCallbackWithOutput< PP_FileInfo > & callback)

Query() queries info about a file or directory.

You must have access to read this file or directory if it exists in the external filesystem.

Parameters:
[in]callbackA CompletionCallbackWithOutput to be called upon completion of Query().
Returns:
An int32_t containing an error code from pp_errors.h.

ReadDirectoryEntries() Reads all entries in the directory.

Parameters:
[in]ccA CompletionCallbackWithOutput to be called upon completion of ReadDirectoryEntries(). On success, the directory entries will be passed to the given function.

Normally you would use a CompletionCallbackFactory to allow callbacks to be bound to your class. See completion_callback_factory.h for more discussion on how to use this. Your callback will generally look like:

   void OnReadDirectoryEntries(
       int32_t result,
       const std::vector<DirectoryEntry>& entries) {
     if (result == PP_OK)
       // use entries...
   }
Returns:
An int32_t containing an error code from pp_errors.h.
int32_t pp::FileRef::Rename(const FileRefnew_file_ref,
const CompletionCallbackcc 
)

Rename() renames a file or directory.

Argument new_file_ref must refer to files in the same file system as in this object. It is an error to rename a file or directory that is in use. It is not valid to rename a file in the external file system.

Parameters:
[in]new_file_refA FileRef corresponding to a new file reference.
[in]ccA CompletionCallback to be called upon completion of Rename().
Returns:
An int32_t containing an error code from pp_errors.h.
int32_t pp::FileRef::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
const CompletionCallbackcc 
)

Touch() Updates time stamps for a file.

You must have write access to the file if it exists in the external filesystem.

Parameters:
[in]last_access_timeThe last time the file was accessed.
[in]last_modified_timeThe last time the file was modified.
[in]ccA CompletionCallback to be called upon completion of Touch().
Returns:
An int32_t containing an error code from pp_errors.h.

The documentation for this class was generated from the following file:
This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.