/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/**
* This file defines the API to create a file reference or "weak pointer" to a
* file in a file system.
*/
label Chrome {
M14 = 1.0,
M28 = 1.1
};
/**
* The PPB_FileRef
struct represents a "weak pointer" to a file in
* a file system. This struct contains a PP_FileSystemType
* identifier and a file path string.
*/
interface PPB_FileRef {
/**
* Create() creates a weak pointer to a file in the given file system. File
* paths are POSIX style.
*
* @param[in] resource A PP_Resource
corresponding to a file
* system.
* @param[in] path A path to the file.
*
* @return A PP_Resource
corresponding to a file reference if
* successful or 0 if the path is malformed.
*/
PP_Resource Create([in] PP_Resource file_system, [in] str_t path);
/**
* IsFileRef() determines if the provided resource is a file reference.
*
* @param[in] resource A PP_Resource
corresponding to a file
* reference.
*
* @return PP_TRUE
if the resource is a
* PPB_FileRef
, PP_FALSE
if the resource is
* invalid or some type other than PPB_FileRef
.
*/
PP_Bool IsFileRef([in] PP_Resource resource);
/**
* GetFileSystemType() returns the type of the file system.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
*
* @return A PP_FileSystemType
with the file system type if
* valid or PP_FILESYSTEMTYPE_INVALID
if the provided resource
* is not a valid file reference.
*/
PP_FileSystemType GetFileSystemType([in] PP_Resource file_ref);
/**
* GetName() returns the name of the file.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
*
* @return A PP_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.
*/
PP_Var GetName([in] PP_Resource file_ref);
/**
* GetPath() returns the absolute path of the file.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
*
* @return A PP_Var
containing the absolute path of the file.
* This function fails if the file system type is
* PP_FileSystemType_External
.
*/
PP_Var GetPath([in] PP_Resource file_ref);
/**
* GetParent() returns the parent directory of this file. If
* file_ref
points to the root of the filesystem, then the root
* is returned.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
*
* @return A PP_Resource
containing the parent directory of the
* file. This function fails if the file system type is
* PP_FileSystemType_External
.
*/
PP_Resource GetParent([in] PP_Resource file_ref);
/**
* MakeDirectory() makes a new directory in the file system as well as any
* parent directories if the make_ancestors
argument is
* PP_TRUE
. It is not valid to make a directory in the external
* file system.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
* @param[in] make_ancestors A PP_Bool
set to
* PP_TRUE
to make ancestor directories or PP_FALSE
* if ancestor directories are not needed.
*
* @return An int32_t containing an error code from pp_errors.h
.
* Succeeds if the directory already exists. Fails if ancestor directories
* do not exist and make_ancestors
was passed as
* PP_FALSE
.
*/
int32_t MakeDirectory([in] PP_Resource directory_ref,
[in] PP_Bool make_ancestors,
[in] PP_CompletionCallback callback);
/**
* Touch() Updates time stamps for a file. You must have write access to the
* file if it exists in the external filesystem.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
* @param[in] last_access_time The last time the file was accessed.
* @param[in] last_modified_time The last time the file was modified.
* @param[in] callback A PP_CompletionCallback
to be called upon
* completion of Touch().
*
* @return An int32_t containing an error code from pp_errors.h
.
*/
int32_t Touch([in] PP_Resource file_ref,
[in] PP_Time last_access_time,
[in] PP_Time last_modified_time,
[in] PP_CompletionCallback callback);
/**
* 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.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
* @param[in] callback A PP_CompletionCallback
to be called upon
* completion of Delete().
*
* @return An int32_t containing an error code from pp_errors.h
.
*/
int32_t Delete([in] PP_Resource file_ref,
[in] PP_CompletionCallback callback);
/**
* Rename() renames a file or directory. Arguments file_ref
and
* new_file_ref
must both refer to files in the same file
* system. 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.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
* @param[in] new_file_ref A PP_Resource
corresponding to a new
* file reference.
* @param[in] callback A PP_CompletionCallback
to be called upon
* completion of Rename().
*
* @return An int32_t containing an error code from pp_errors.h
.
*/
int32_t Rename([in] PP_Resource file_ref,
[in] PP_Resource new_file_ref,
[in] PP_CompletionCallback 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.
*
* @param[in] file_ref A PP_Resource
corresponding to a file
* reference.
* @param[out] info A pointer to a PP_FileInfo
which will be
* populated with information about the file or directory.
* @param[in] callback A PP_CompletionCallback
to be called upon
* completion of Query().
*
* @return An int32_t containing an error code from pp_errors.h
.
*/
[version=1.1]
int32_t Query([in] PP_Resource file_ref,
[out] PP_FileInfo info,
[in] PP_CompletionCallback callback);
/**
* ReadDirectoryEntries() reads all entries in a directory.
*
* @param[in] file_ref A PP_Resource
corresponding to a directory
* reference.
* @param[in] output An output array which will receive
* PP_DirectoryEntry
objects on success.
* @param[in] callback A PP_CompletionCallback
to run on
* completion.
*
* @return An int32_t containing an error code from pp_errors.h
.
*/
[version=1.1]
int32_t ReadDirectoryEntries([in] PP_Resource file_ref,
[in] PP_ArrayOutput output,
[in] PP_CompletionCallback callback);
};