Native Client

pp::FileRef Class Reference

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

Inheritance diagram for pp::FileRef:

List of all members.

Public 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 (const CompletionCallback &cc)
int32_t MakeDirectoryIncludingAncestors (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 and Destructor Details

pp::FileRef::FileRef ( ) [inline]

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 FileSystem file_system,
const char *  path 
)

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

File paths are POSIX style.

Parameters:
[in]file_systemA FileSystem corresponding to a file system type.
[in]pathA path to the file.
pp::FileRef::FileRef ( const FileRef other)

The copy constructor for FileRef.

Parameters:
[in]otherA pointer to a FileRef.

Function Details

int32_t pp::FileRef::Delete ( const CompletionCallback cc)

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.
Var pp::FileRef::GetName ( ) const

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.
FileRef pp::FileRef::GetParent ( ) const

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.
Var pp::FileRef::GetPath ( ) const

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 ( const CompletionCallback cc)

MakeDirectory() makes a new directory in the file system.

It is not valid to make a directory in the external file system. Note: Use MakeDirectoryIncludingAncestors() to create parent directories.

Parameters:
[in]ccA CompletionCallback to be called upon completion of MakeDirectory().
Returns:
An int32_t containing an error code from pp_errors.h. Succeeds if the directory already exists. Fails if ancestor directortories do not exist (see MakeDirectoryIncludingAncestors for the alternative).
int32_t pp::FileRef::MakeDirectoryIncludingAncestors ( const CompletionCallback cc)

MakeDirectoryIncludingAncestors() makes a new directory in the file system as well as any parent directories.

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

Parameters:
[in]ccA CompletionCallback to be called upon completion of MakeDirectoryIncludingAncestors().
Returns:
An int32_t containing an error code from pp_errors.h. Succeeds if the directory already exists.
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.
int32_t pp::FileRef::ReadDirectoryEntries ( const CompletionCallbackWithOutput< std::vector< DirectoryEntry > > &  callback)

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 FileRef new_file_ref,
const CompletionCallback cc 
)

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 CompletionCallback cc 
)

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:

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.