Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
FileUtils Class Referenceabstract

Helper class to handle file operations. More...

Inherited by FileUtilsTizen.

Public Member Functions

virtual ~FileUtils ()
 The destructor of FileUtils.
 
virtual void purgeCachedEntries ()
 Purges full path caches.
 
local purgeCachedEntries ()
 Purges full path caches.
 
virtual std::string getStringFromFile (const std::string &filename)
 Gets string from a file.
 
var getStringFromFile ( var filename)
 Gets string from a file.
 
local getStringFromFile ( local filename)
 Gets string from a file.
 
virtual void getStringFromFile (const std::string &path, std::function< void(std::string)> callback)
 Gets string from a file, async off the main cocos thread. More...
 
virtual Data getDataFromFile (const std::string &filename)
 Creates binary data from a file. More...
 
virtual void getDataFromFile (const std::string &filename, std::function< void(Data)> callback)
 Gets a binary data object from a file, async off the main cocos thread. More...
 
var getDataFromFile ( var filename, var callback)
 Gets a binary data object from a file, async off the main cocos thread. More...
 
local getDataFromFile ( local filename, local callback)
 Gets a binary data object from a file, async off the main cocos thread. More...
 
template<typename T , typename Enable = typename std::enable_if< std::is_base_of< ResizableBuffer, ResizableBufferAdapter<T> >::value >::type>
Status getContents (const std::string &filename, T *buffer)
 Gets whole file contents as string from a file. More...
 
template<typename T , typename Enable = typename std::enable_if< std::is_base_of< ResizableBuffer, ResizableBufferAdapter<T> >::value >::type>
var getContents ( var filename, var buffer)
 Gets whole file contents as string from a file. More...
 
template<typename T , typename Enable = typename std::enable_if< std::is_base_of< ResizableBuffer, ResizableBufferAdapter<T> >::value >::type>
local getContents ( local filename, local buffer)
 Gets whole file contents as string from a file. More...
 
virtual unsigned char * getFileData (const std::string &filename, const char *mode, ssize_t *size)
 Gets resource file data. More...
 
var getFileData ( var filename, var mode, var size)
 Gets resource file data. More...
 
local getFileData ( local filename, local mode, local size)
 Gets resource file data. More...
 
virtual unsigned char * getFileDataFromZip (const std::string &zipFilePath, const std::string &filename, ssize_t *size)
 Gets resource file data from a zip file. More...
 
virtual std::string fullPathForFilename (const std::string &filename) const
 Returns the fullpath for a given filename. More...
 
var fullPathForFilename ( var filename)
 Returns the fullpath for a given filename. More...
 
local fullPathForFilename ( local filename)
 Returns the fullpath for a given filename. More...
 
virtual void loadFilenameLookupDictionaryFromFile (const std::string &filename)
 Loads the filenameLookup dictionary from the contents of a filename. More...
 
var loadFilenameLookup ( var filename)
 Loads the filenameLookup dictionary from the contents of a filename. More...
 
local loadFilenameLookup ( local filename)
 Loads the filenameLookup dictionary from the contents of a filename. More...
 
virtual void setFilenameLookupDictionary (const ValueMap &filenameLookupDict)
 Sets the filenameLookup dictionary. More...
 
virtual std::string fullPathFromRelativeFile (const std::string &filename, const std::string &relativeFile)
 Gets full path from a file name and the path of the relative file. More...
 
local fullPathFromRelativeFile ( local filename, local relativeFile)
 Gets full path from a file name and the path of the relative file. More...
 
virtual void setSearchResolutionsOrder (const std::vector< std::string > &searchResolutionsOrder)
 Sets the array that contains the search order of the resources. More...
 
virtual void addSearchResolutionsOrder (const std::string &order, const bool front=false)
 Append search order of the resources. More...
 
local addSearchResolutionsOrder ( local order, local false)
 Append search order of the resources. More...
 
virtual const std::vector
< std::string > & 
getSearchResolutionsOrder () const
 Gets the array that contains the search order of the resources. More...
 
virtual void setSearchPaths (const std::vector< std::string > &searchPaths)
 Sets the array of search paths. More...
 
var setSearchPaths ( var searchPaths)
 Sets the array of search paths. More...
 
const std::string & getDefaultResourceRootPath () const
 Get default resource root path.
 
local getDefaultResourceRootPath ()
 Get default resource root path.
 
void setDefaultResourceRootPath (const std::string &path)
 Set default resource root path.
 
var setDefaultResourceRootPath ( var path)
 Set default resource root path.
 
local setDefaultResourceRootPath ( local path)
 Set default resource root path.
 
void addSearchPath (const std::string &path, const bool front=false)
 Add search path. More...
 
var addSearchPath ( var path, var false)
 Add search path. More...
 
local addSearchPath ( local path, local false)
 Add search path. More...
 
virtual const std::vector
< std::string > & 
getSearchPaths () const
 Gets the array of search paths. More...
 
virtual const std::vector
< std::string > & 
getOriginalSearchPaths () const
 Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. More...
 
local getOriginalSearchPaths ()
 Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. More...
 
virtual std::string getWritablePath () const =0
 Gets the writable path. More...
 
virtual void setWritablePath (const std::string &writablePath)
 Sets writable path.
 
virtual void setPopupNotify (bool notify)
 Sets whether to pop-up a message box when failed to load an image.
 
virtual bool isPopupNotify () const
 Checks whether to pop up a message box when failed to load an image. More...
 
var isPopupNotify ()
 Checks whether to pop up a message box when failed to load an image. More...
 
local isPopupNotify ()
 Checks whether to pop up a message box when failed to load an image. More...
 
virtual ValueMap getValueMapFromFile (const std::string &filename)
 Converts the contents of a file to a ValueMap. More...
 
var getValueMapFromFile ( var filename)
 Converts the contents of a file to a ValueMap. More...
 
local getValueMapFromFile ( local filename)
 Converts the contents of a file to a ValueMap. More...
 
virtual ValueMap getValueMapFromData (const char *filedata, int filesize)
 Converts the contents of a file to a ValueMap. More...
 
var getValueMapFromData ( var filedata, var filesize)
 Converts the contents of a file to a ValueMap. More...
 
virtual bool writeToFile (const ValueMap &dict, const std::string &fullPath)
 write a ValueMap into a plist file More...
 
var writeToFile ( var dict, var fullPath)
 write a ValueMap into a plist file More...
 
local writeToFile ( local dict, local fullPath)
 write a ValueMap into a plist file More...
 
virtual bool writeStringToFile (const std::string &dataStr, const std::string &fullPath)
 write a string into a file More...
 
local writeStringToFile ( local dataStr, local fullPath)
 write a string into a file More...
 
virtual void writeStringToFile (std::string dataStr, const std::string &fullPath, std::function< void(bool)> callback)
 Write a string to a file, done async off the main cocos thread Use this function if you need file access without blocking the main thread. More...
 
local writeStringToFile ( local dataStr, local fullPath, local callback)
 Write a string to a file, done async off the main cocos thread Use this function if you need file access without blocking the main thread. More...
 
virtual bool writeDataToFile (const Data &data, const std::string &fullPath)
 write Data into a file More...
 
virtual void writeDataToFile (Data data, const std::string &fullPath, std::function< void(bool)> callback)
 Write Data into a file, done async off the main cocos thread. More...
 
var writeDataToFile ( var data, var fullPath, var callback)
 Write Data into a file, done async off the main cocos thread. More...
 
local writeDataToFile ( local data, local fullPath, local callback)
 Write Data into a file, done async off the main cocos thread. More...
 
virtual bool writeValueMapToFile (const ValueMap &dict, const std::string &fullPath)
 write ValueMap into a plist file More...
 
var writeValueMapToFile ( var dict, var fullPath)
 write ValueMap into a plist file More...
 
local writeValueMapToFile ( local dict, local fullPath)
 write ValueMap into a plist file More...
 
virtual void writeValueMapToFile (ValueMap dict, const std::string &fullPath, std::function< void(bool)> callback)
 Write a ValueMap into a file, done async off the main cocos thread. More...
 
var writeValueMapToFile ( var dict, var fullPath, var callback)
 Write a ValueMap into a file, done async off the main cocos thread. More...
 
local writeValueMapToFile ( local dict, local fullPath, local callback)
 Write a ValueMap into a file, done async off the main cocos thread. More...
 
virtual bool writeValueVectorToFile (const ValueVector &vecData, const std::string &fullPath)
 write ValueVector into a plist file More...
 
var writeValueVectorToFile ( var vecData, var fullPath)
 write ValueVector into a plist file More...
 
local writeValueVectorToFile ( local vecData, local fullPath)
 write ValueVector into a plist file More...
 
virtual void writeValueVectorToFile (ValueVector vecData, const std::string &fullPath, std::function< void(bool)> callback)
 Write a ValueVector into a file, done async off the main cocos thread. More...
 
var writeValueVectorToFile ( var vecData, var fullPath, var callback)
 Write a ValueVector into a file, done async off the main cocos thread. More...
 
local writeValueVectorToFile ( local vecData, local fullPath, local callback)
 Write a ValueVector into a file, done async off the main cocos thread. More...
 
virtual std::string getSuitableFOpen (const std::string &filenameUtf8) const
 Windows fopen can't support UTF-8 filename Need convert all parameters fopen and other 3rd-party libs. More...
 
virtual bool isFileExist (const std::string &filename) const
 Checks whether a file exists. More...
 
virtual void isFileExist (const std::string &filename, std::function< void(bool)> callback)
 Checks if a file exists, done async off the main cocos thread. More...
 
virtual std::string getFileExtension (const std::string &filePath) const
 Gets filename extension is a suffix (separated from the base filename by a dot) in lower case. More...
 
virtual bool isAbsolutePath (const std::string &path) const
 Checks whether the path is an absolute path. More...
 
virtual bool isDirectoryExist (const std::string &dirPath) const
 Checks whether the path is a directory. More...
 
local isDirectoryExist ( local dirPath)
 Checks whether the path is a directory. More...
 
virtual void isDirectoryExist (const std::string &fullPath, std::function< void(bool)> callback)
 Checks whether the absoulate path is a directory, async off of the main cocos thread. More...
 
local isDirectoryExist ( local fullPath, local callback)
 Checks whether the absoulate path is a directory, async off of the main cocos thread. More...
 
virtual bool createDirectory (const std::string &dirPath)
 Creates a directory. More...
 
virtual void createDirectory (const std::string &dirPath, std::function< void(bool)> callback)
 Create a directory, async off the main cocos thread. More...
 
virtual bool removeDirectory (const std::string &dirPath)
 Removes a directory. More...
 
virtual void removeDirectory (const std::string &dirPath, std::function< void(bool)> callback)
 Removes a directory, async off the main cocos thread. More...
 
virtual bool removeFile (const std::string &filepath)
 Removes a file. More...
 
var removeFile ( var filepath)
 Removes a file. More...
 
virtual void removeFile (const std::string &filepath, std::function< void(bool)> callback)
 Removes a file, async off the main cocos thread. More...
 
local removeFile ( local filepath, local callback)
 Removes a file, async off the main cocos thread. More...
 
virtual bool renameFile (const std::string &path, const std::string &oldname, const std::string &name)
 Renames a file under the given directory. More...
 
var renameFile ( var path, var oldname, var name)
 Renames a file under the given directory. More...
 
local renameFile ( local path, local oldname, local name)
 Renames a file under the given directory. More...
 
virtual void renameFile (const std::string &path, const std::string &oldname, const std::string &name, std::function< void(bool)> callback)
 Renames a file under the given directory, async off the main cocos thread. More...
 
var renameFile ( var path, var oldname, var name, var callback)
 Renames a file under the given directory, async off the main cocos thread. More...
 
local renameFile ( local path, local oldname, local name, local callback)
 Renames a file under the given directory, async off the main cocos thread. More...
 
virtual bool renameFile (const std::string &oldfullpath, const std::string &newfullpath)
 Renames a file under the given directory. More...
 
virtual void renameFile (const std::string &oldfullpath, const std::string &newfullpath, std::function< void(bool)> callback)
 Renames a file under the given directory, async off the main cocos thread. More...
 
local renameFile ( local oldfullpath, local newfullpath, local callback)
 Renames a file under the given directory, async off the main cocos thread. More...
 
virtual long getFileSize (const std::string &filepath)
 Retrieve the file size. More...
 
virtual void getFileSize (const std::string &filepath, std::function< void(long)> callback)
 Retrieve the file size, async off the main cocos thread. More...
 
var getFileSize ( var filepath, var callback)
 Retrieve the file size, async off the main cocos thread. More...
 
local getFileSize ( local filepath, local callback)
 Retrieve the file size, async off the main cocos thread. More...
 
virtual std::vector< std::string > listFiles (const std::string &dirPath) const
 List all files in a directory. More...
 
var listFiles ( var dirPath)
 List all files in a directory. More...
 
local listFiles ( local dirPath)
 List all files in a directory. More...
 
virtual void listFilesAsync (const std::string &dirPath, std::function< void(std::vector< std::string >)> callback) const
 List all files in a directory async, off of the main cocos thread. More...
 
virtual void listFilesRecursively (const std::string &dirPath, std::vector< std::string > *files) const
 List all files recursively in a directory. More...
 
local listFilesRecursively ( local dirPath, local files)
 List all files recursively in a directory. More...
 
virtual void listFilesRecursivelyAsync (const std::string &dirPath, std::function< void(std::vector< std::string >)> callback) const
 List all files recursively in a directory, async off the main cocos thread. More...
 
const std::unordered_map
< std::string, std::string > & 
getFullPathCache () const
 Returns the full path cache. More...
 
local getFullPathCache ()
 Returns the full path cache. More...
 
virtual std::string getNewFilename (const std::string &filename) const
 Gets the new filename from the filename lookup dictionary. More...
 
var getNewFilename ( var filename)
 Gets the new filename from the filename lookup dictionary. More...
 
local getNewFilename ( local filename)
 Gets the new filename from the filename lookup dictionary. More...
 

Static Public Member Functions

static FileUtilsgetInstance ()
 Gets the instance of FileUtils.
 
var getInstance ()
 Gets the instance of FileUtils.
 
local getInstance ()
 Gets the instance of FileUtils.
 
static void destroyInstance ()
 Destroys the instance of FileUtils.
 
local destroyInstance ()
 Destroys the instance of FileUtils.
 
static void setDelegate (FileUtils *delegate)
 You can inherit from platform dependent implementation of FileUtils, such as FileUtilsAndroid, and use this function to set delegate, then FileUtils will invoke delegate's implementation. More...
 
static FileUtilssharedFileUtils ()
static void purgeFileUtils ()

Detailed Description

Helper class to handle file operations.

Member Function Documentation

static void setDelegate ( FileUtils delegate)
static

You can inherit from platform dependent implementation of FileUtils, such as FileUtilsAndroid, and use this function to set delegate, then FileUtils will invoke delegate's implementation.

For example, your resources are encrypted, so you need to decrypt it after reading data from resources, then you can implement all getXXX functions, and engine will invoke your own getXX functions when reading data of resources.

If you don't want to system default implementation after setting delegate, you can just pass nullptr to this function.

Warning
It will delete previous delegate
var setDelegate ( var  delegate)
static

You can inherit from platform dependent implementation of FileUtils, such as FileUtilsAndroid, and use this function to set delegate, then FileUtils will invoke delegate's implementation.

For example, your resources are encrypted, so you need to decrypt it after reading data from resources, then you can implement all getXXX functions, and engine will invoke your own getXX functions when reading data of resources.

If you don't want to system default implementation after setting delegate, you can just pass nullptr to this function.

Warning
It will delete previous delegate
static FileUtils* sharedFileUtils ( )
inlinestatic
var sharedFileUtils ( )
inlinestatic
local sharedFileUtils ( )
inlinestatic
static void purgeFileUtils ( )
inlinestatic
var purgeFileUtils ( )
inlinestatic
local purgeFileUtils ( )
inlinestatic
virtual void getStringFromFile ( const std::string &  path,
std::function< void(std::string)>  callback 
)
virtual

Gets string from a file, async off the main cocos thread.

Parameters
pathfilepath for the string to be read. Can be relative or absolute path
callbackFunction that will be called when file is read. Will be called on the main cocos thread.
var getStringFromFile ( var  path,
var  callback 
)
virtual

Gets string from a file, async off the main cocos thread.

Parameters
pathfilepath for the string to be read. Can be relative or absolute path
callbackFunction that will be called when file is read. Will be called on the main cocos thread.
local getStringFromFile ( local  path,
local  callback 
)
virtual

Gets string from a file, async off the main cocos thread.

Parameters
pathfilepath for the string to be read. Can be relative or absolute path
callbackFunction that will be called when file is read. Will be called on the main cocos thread.
virtual Data getDataFromFile ( const std::string &  filename)
virtual

Creates binary data from a file.

Returns
A data object.
var getDataFromFile ( var  filename)
virtual

Creates binary data from a file.

Returns
A data object.
local getDataFromFile ( local  filename)
virtual

Creates binary data from a file.

Returns
A data object.
virtual void getDataFromFile ( const std::string &  filename,
std::function< void(Data)>  callback 
)
virtual

Gets a binary data object from a file, async off the main cocos thread.

Parameters
filenamefilepath for the data to be read. Can be relative or absolute path
callbackFunction that will be called when file is read. Will be called on the main cocos thread.
var getDataFromFile ( var  filename,
var  callback 
)
virtual

Gets a binary data object from a file, async off the main cocos thread.

Parameters
filenamefilepath for the data to be read. Can be relative or absolute path
callbackFunction that will be called when file is read. Will be called on the main cocos thread.
local getDataFromFile ( local  filename,
local  callback 
)
virtual

Gets a binary data object from a file, async off the main cocos thread.

Parameters
filenamefilepath for the data to be read. Can be relative or absolute path
callbackFunction that will be called when file is read. Will be called on the main cocos thread.
Status getContents ( const std::string &  filename,
T *  buffer 
)
inline

Gets whole file contents as string from a file.

Unlike getStringFromFile, these getContents methods:

  • read file in binary mode (does not convert CRLF to LF).
  • does not truncate the string when '\0' is found (returned string of getContents may have '\0' in the middle.).

The template version of can accept cocos2d::Data, std::basic_string and std::vector.

std::string sbuf;
FileUtils::getInstance()->getContents("path/to/file", &sbuf);
std::vector<int> vbuf;
FileUtils::getInstance()->getContents("path/to/file", &vbuf);
Data dbuf;
FileUtils::getInstance()->getContents("path/to/file", &dbuf);

Note: if you read to std::vector<T> and std::basic_string<T> where T is not 8 bit type, you may get 0 ~ sizeof(T)-1 bytes padding.

  • To write a new buffer class works with getContents, just extend ResizableBuffer.
  • To write a adapter for existing class, write a specialized ResizableBufferAdapter for that class, see follow code.
NS_CC_BEGIN // ResizableBufferAdapter needed in cocos2d namespace.
template<>
class ResizableBufferAdapter<AlreadyExistsBuffer> : public ResizableBuffer {
public:
ResizableBufferAdapter(AlreadyExistsBuffer* buffer) {
// your code here
}
virtual void resize(size_t size) override {
// your code here
}
virtual void* buffer() const override {
// your code here
}
};
NS_CC_END
Parameters
[in]filenameThe resource file name which contains the path.
[out]bufferThe buffer where the file contents are store to.
Returns
Returns:
  • Status::OK when there is no error, the buffer is filled with the contents of file.
  • Status::NotExists when file not exists, the buffer will not changed.
  • Status::OpenFailed when cannot open file, the buffer will not changed.
  • Status::ReadFailed when read end up before read whole, the buffer will fill with already read bytes.
  • Status::NotInitialized when FileUtils is not initializes, the buffer will not changed.
  • Status::TooLarge when there file to be read is too large (> 2^32-1), the buffer will not changed.
  • Status::ObtainSizeFailed when failed to obtain the file size, the buffer will not changed.
var getContents ( var  filename,
var  buffer 
)
inline

Gets whole file contents as string from a file.

Unlike getStringFromFile, these getContents methods:

  • read file in binary mode (does not convert CRLF to LF).
  • does not truncate the string when '\0' is found (returned string of getContents may have '\0' in the middle.).

The template version of can accept cocos2d::Data, std::basic_string and std::vector.

std::string sbuf;
FileUtils::getInstance()->getContents("path/to/file", &sbuf);
std::vector<int> vbuf;
FileUtils::getInstance()->getContents("path/to/file", &vbuf);
Data dbuf;
FileUtils::getInstance()->getContents("path/to/file", &dbuf);

Note: if you read to std::vector<T> and std::basic_string<T> where T is not 8 bit type, you may get 0 ~ sizeof(T)-1 bytes padding.

  • To write a new buffer class works with getContents, just extend ResizableBuffer.
  • To write a adapter for existing class, write a specialized ResizableBufferAdapter for that class, see follow code.
NS_CC_BEGIN // ResizableBufferAdapter needed in cocos2d namespace.
template<>
class ResizableBufferAdapter<AlreadyExistsBuffer> : public ResizableBuffer {
public:
ResizableBufferAdapter(AlreadyExistsBuffer* buffer) {
// your code here
}
virtual void resize(size_t size) override {
// your code here
}
virtual void* buffer() const override {
// your code here
}
};
NS_CC_END
Parameters
[in]filenameThe resource file name which contains the path.
[out]bufferThe buffer where the file contents are store to.
Returns
Returns:
  • Status::OK when there is no error, the buffer is filled with the contents of file.
  • Status::NotExists when file not exists, the buffer will not changed.
  • Status::OpenFailed when cannot open file, the buffer will not changed.
  • Status::ReadFailed when read end up before read whole, the buffer will fill with already read bytes.
  • Status::NotInitialized when FileUtils is not initializes, the buffer will not changed.
  • Status::TooLarge when there file to be read is too large (> 2^32-1), the buffer will not changed.
  • Status::ObtainSizeFailed when failed to obtain the file size, the buffer will not changed.
local getContents ( local  filename,
local  buffer 
)
inline

Gets whole file contents as string from a file.

Unlike getStringFromFile, these getContents methods:

  • read file in binary mode (does not convert CRLF to LF).
  • does not truncate the string when '\0' is found (returned string of getContents may have '\0' in the middle.).

The template version of can accept cocos2d::Data, std::basic_string and std::vector.

std::string sbuf;
FileUtils::getInstance()->getContents("path/to/file", &sbuf);
std::vector<int> vbuf;
FileUtils::getInstance()->getContents("path/to/file", &vbuf);
Data dbuf;
FileUtils::getInstance()->getContents("path/to/file", &dbuf);

Note: if you read to std::vector<T> and std::basic_string<T> where T is not 8 bit type, you may get 0 ~ sizeof(T)-1 bytes padding.

  • To write a new buffer class works with getContents, just extend ResizableBuffer.
  • To write a adapter for existing class, write a specialized ResizableBufferAdapter for that class, see follow code.
NS_CC_BEGIN // ResizableBufferAdapter needed in cocos2d namespace.
template<>
class ResizableBufferAdapter<AlreadyExistsBuffer> : public ResizableBuffer {
public:
ResizableBufferAdapter(AlreadyExistsBuffer* buffer) {
// your code here
}
virtual void resize(size_t size) override {
// your code here
}
virtual void* buffer() const override {
// your code here
}
};
NS_CC_END
Parameters
[in]filenameThe resource file name which contains the path.
[out]bufferThe buffer where the file contents are store to.
Returns
Returns:
  • Status::OK when there is no error, the buffer is filled with the contents of file.
  • Status::NotExists when file not exists, the buffer will not changed.
  • Status::OpenFailed when cannot open file, the buffer will not changed.
  • Status::ReadFailed when read end up before read whole, the buffer will fill with already read bytes.
  • Status::NotInitialized when FileUtils is not initializes, the buffer will not changed.
  • Status::TooLarge when there file to be read is too large (> 2^32-1), the buffer will not changed.
  • Status::ObtainSizeFailed when failed to obtain the file size, the buffer will not changed.
virtual unsigned char* getFileData ( const std::string &  filename,
const char *  mode,
ssize_t *  size 
)
virtual

Gets resource file data.

Parameters
[in]filenameThe resource file name which contains the path.
[in]modeThe read mode of the file.
[out]sizeIf the file read operation succeeds, it will be the data size, otherwise 0.
Returns
Upon success, a pointer to the data is returned, otherwise NULL.
Warning
Recall: you are responsible for calling free() on any Non-NULL pointer returned.
var getFileData ( var  filename,
var  mode,
var  size 
)
virtual

Gets resource file data.

Parameters
[in]filenameThe resource file name which contains the path.
[in]modeThe read mode of the file.
[out]sizeIf the file read operation succeeds, it will be the data size, otherwise 0.
Returns
Upon success, a pointer to the data is returned, otherwise NULL.
Warning
Recall: you are responsible for calling free() on any Non-NULL pointer returned.
local getFileData ( local  filename,
local  mode,
local  size 
)
virtual

Gets resource file data.

Parameters
[in]filenameThe resource file name which contains the path.
[in]modeThe read mode of the file.
[out]sizeIf the file read operation succeeds, it will be the data size, otherwise 0.
Returns
Upon success, a pointer to the data is returned, otherwise NULL.
Warning
Recall: you are responsible for calling free() on any Non-NULL pointer returned.
virtual unsigned char*
getFileDataFromZip
( const std::string &  zipFilePath,
const std::string &  filename,
ssize_t *  size 
)
virtual

Gets resource file data from a zip file.

Parameters
[in]filenameThe resource file name which contains the relative path of the zip file.
[out]sizeIf the file read operation succeeds, it will be the data size, otherwise 0.
Returns
Upon success, a pointer to the data is returned, otherwise nullptr.
Warning
Recall: you are responsible for calling free() on any Non-nullptr pointer returned.
var getFileDataFromZip ( var  zipFilePath,
var  filename,
var  size 
)
virtual

Gets resource file data from a zip file.

Parameters
[in]filenameThe resource file name which contains the relative path of the zip file.
[out]sizeIf the file read operation succeeds, it will be the data size, otherwise 0.
Returns
Upon success, a pointer to the data is returned, otherwise nullptr.
Warning
Recall: you are responsible for calling free() on any Non-nullptr pointer returned.
local getFileDataFromZip ( local  zipFilePath,
local  filename,
local  size 
)
virtual

Gets resource file data from a zip file.

Parameters
[in]filenameThe resource file name which contains the relative path of the zip file.
[out]sizeIf the file read operation succeeds, it will be the data size, otherwise 0.
Returns
Upon success, a pointer to the data is returned, otherwise nullptr.
Warning
Recall: you are responsible for calling free() on any Non-nullptr pointer returned.
virtual std::string
fullPathForFilename
( const std::string &  filename) const
virtual

Returns the fullpath for a given filename.

First it will try to get a new filename from the "filenameLookup" dictionary. If a new filename can't be found on the dictionary, it will use the original filename. Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. The file search is based on the array element order of search paths and resolution directories.

For instance:

We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths,
and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd")
to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/".

If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains key: sprite.png -> value: sprite.pvr.gz. Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows:

/mnt/sdcard/resources-ipadhd/sprite.pvr.gz      (if not found, search next)
/mnt/sdcard/resources-ipad/sprite.pvr.gz        (if not found, search next)
/mnt/sdcard/resources-iphonehd/sprite.pvr.gz    (if not found, search next)
/mnt/sdcard/sprite.pvr.gz                       (if not found, search next)
internal_dir/resources-ipadhd/sprite.pvr.gz     (if not found, search next)
internal_dir/resources-ipad/sprite.pvr.gz       (if not found, search next)
internal_dir/resources-iphonehd/sprite.pvr.gz   (if not found, search next)
internal_dir/sprite.pvr.gz                      (if not found, return "sprite.png")

If the filename contains relative path like "gamescene/uilayer/sprite.png", and the mapping in fileLookup dictionary contains key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz. The file search order will be:

 /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz      (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz        (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz    (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz                       (if not found, search next)
 internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz     (if not found, search next)
 internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz       (if not found, search next)
 internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz   (if not found, search next)
 internal_dir/gamescene/uilayer/sprite.pvr.gz                      (if not found, return "gamescene/uilayer/sprite.png")

If the new file can't be found on the file system, it will return the parameter filename directly.

This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, you might need to load different resources for a given file in the different platforms.

Since
v2.1
var fullPathForFilename ( var  filename)
virtual

Returns the fullpath for a given filename.

First it will try to get a new filename from the "filenameLookup" dictionary. If a new filename can't be found on the dictionary, it will use the original filename. Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. The file search is based on the array element order of search paths and resolution directories.

For instance:

We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths,
and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd")
to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/".

If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains key: sprite.png -> value: sprite.pvr.gz. Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows:

/mnt/sdcard/resources-ipadhd/sprite.pvr.gz      (if not found, search next)
/mnt/sdcard/resources-ipad/sprite.pvr.gz        (if not found, search next)
/mnt/sdcard/resources-iphonehd/sprite.pvr.gz    (if not found, search next)
/mnt/sdcard/sprite.pvr.gz                       (if not found, search next)
internal_dir/resources-ipadhd/sprite.pvr.gz     (if not found, search next)
internal_dir/resources-ipad/sprite.pvr.gz       (if not found, search next)
internal_dir/resources-iphonehd/sprite.pvr.gz   (if not found, search next)
internal_dir/sprite.pvr.gz                      (if not found, return "sprite.png")

If the filename contains relative path like "gamescene/uilayer/sprite.png", and the mapping in fileLookup dictionary contains key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz. The file search order will be:

 /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz      (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz        (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz    (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz                       (if not found, search next)
 internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz     (if not found, search next)
 internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz       (if not found, search next)
 internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz   (if not found, search next)
 internal_dir/gamescene/uilayer/sprite.pvr.gz                      (if not found, return "gamescene/uilayer/sprite.png")

If the new file can't be found on the file system, it will return the parameter filename directly.

This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, you might need to load different resources for a given file in the different platforms.

Since
v2.1
local fullPathForFilename ( local  filename)
virtual

Returns the fullpath for a given filename.

First it will try to get a new filename from the "filenameLookup" dictionary. If a new filename can't be found on the dictionary, it will use the original filename. Then it will try to obtain the full path of the filename using the FileUtils search rules: resolutions, and search paths. The file search is based on the array element order of search paths and resolution directories.

For instance:

We set two elements("/mnt/sdcard/", "internal_dir/") to search paths vector by setSearchPaths,
and set three elements("resources-ipadhd/", "resources-ipad/", "resources-iphonehd")
to resolutions vector by setSearchResolutionsOrder. The "internal_dir" is relative to "Resources/".

If we have a file named 'sprite.png', the mapping in fileLookup dictionary contains key: sprite.png -> value: sprite.pvr.gz. Firstly, it will replace 'sprite.png' with 'sprite.pvr.gz', then searching the file sprite.pvr.gz as follows:

/mnt/sdcard/resources-ipadhd/sprite.pvr.gz      (if not found, search next)
/mnt/sdcard/resources-ipad/sprite.pvr.gz        (if not found, search next)
/mnt/sdcard/resources-iphonehd/sprite.pvr.gz    (if not found, search next)
/mnt/sdcard/sprite.pvr.gz                       (if not found, search next)
internal_dir/resources-ipadhd/sprite.pvr.gz     (if not found, search next)
internal_dir/resources-ipad/sprite.pvr.gz       (if not found, search next)
internal_dir/resources-iphonehd/sprite.pvr.gz   (if not found, search next)
internal_dir/sprite.pvr.gz                      (if not found, return "sprite.png")

If the filename contains relative path like "gamescene/uilayer/sprite.png", and the mapping in fileLookup dictionary contains key: gamescene/uilayer/sprite.png -> value: gamescene/uilayer/sprite.pvr.gz. The file search order will be:

 /mnt/sdcard/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz      (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/resources-ipad/sprite.pvr.gz        (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz    (if not found, search next)
 /mnt/sdcard/gamescene/uilayer/sprite.pvr.gz                       (if not found, search next)
 internal_dir/gamescene/uilayer/resources-ipadhd/sprite.pvr.gz     (if not found, search next)
 internal_dir/gamescene/uilayer/resources-ipad/sprite.pvr.gz       (if not found, search next)
 internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz   (if not found, search next)
 internal_dir/gamescene/uilayer/sprite.pvr.gz                      (if not found, return "gamescene/uilayer/sprite.png")

If the new file can't be found on the file system, it will return the parameter filename directly.

This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, you might need to load different resources for a given file in the different platforms.

Since
v2.1
virtual void
loadFilenameLookupDictionaryFromFile
( const std::string &  filename)
virtual

Loads the filenameLookup dictionary from the contents of a filename.

Note
The plist file name should follow the format below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>filenames</key>
<dict>
<key>sounds/click.wav</key>
<string>sounds/click.caf</string>
<key>sounds/endgame.wav</key>
<string>sounds/endgame.caf</string>
<key>sounds/gem-0.wav</key>
<string>sounds/gem-0.caf</string>
</dict>
<key>metadata</key>
<dict>
<key>version</key>
<integer>1</integer>
</dict>
</dict>
</plist>
Parameters
filenameThe plist file name.
Since
v2.1
var loadFilenameLookup ( var  filename)
virtual

Loads the filenameLookup dictionary from the contents of a filename.

Note
The plist file name should follow the format below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>filenames</key>
<dict>
<key>sounds/click.wav</key>
<string>sounds/click.caf</string>
<key>sounds/endgame.wav</key>
<string>sounds/endgame.caf</string>
<key>sounds/gem-0.wav</key>
<string>sounds/gem-0.caf</string>
</dict>
<key>metadata</key>
<dict>
<key>version</key>
<integer>1</integer>
</dict>
</dict>
</plist>
Parameters
filenameThe plist file name.
Since
v2.1
local loadFilenameLookup ( local  filename)
virtual

Loads the filenameLookup dictionary from the contents of a filename.

Note
The plist file name should follow the format below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>filenames</key>
<dict>
<key>sounds/click.wav</key>
<string>sounds/click.caf</string>
<key>sounds/endgame.wav</key>
<string>sounds/endgame.caf</string>
<key>sounds/gem-0.wav</key>
<string>sounds/gem-0.caf</string>
</dict>
<key>metadata</key>
<dict>
<key>version</key>
<integer>1</integer>
</dict>
</dict>
</plist>
Parameters
filenameThe plist file name.
Since
v2.1
virtual void
setFilenameLookupDictionary
( const ValueMap &  filenameLookupDict)
virtual

Sets the filenameLookup dictionary.

Parameters
filenameLookupDictThe dictionary for replacing filename.
Since
v2.1
var setFilenameLookupDictionary ( var  filenameLookupDict)
virtual

Sets the filenameLookup dictionary.

Parameters
filenameLookupDictThe dictionary for replacing filename.
Since
v2.1
local setFilenameLookupDictionary ( local  filenameLookupDict)
virtual

Sets the filenameLookup dictionary.

Parameters
filenameLookupDictThe dictionary for replacing filename.
Since
v2.1
virtual std::string
fullPathFromRelativeFile
( const std::string &  filename,
const std::string &  relativeFile 
)
virtual

Gets full path from a file name and the path of the relative file.

Parameters
filenameThe file name.
relativeFileThe path of the relative file.
Returns
The full path. e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. )
var fullPathFromRelativeFile ( var  filename,
var  relativeFile 
)
virtual

Gets full path from a file name and the path of the relative file.

Parameters
filenameThe file name.
relativeFileThe path of the relative file.
Returns
The full path. e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. )
local fullPathFromRelativeFile ( local  filename,
local  relativeFile 
)
virtual

Gets full path from a file name and the path of the relative file.

Parameters
filenameThe file name.
relativeFileThe path of the relative file.
Returns
The full path. e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. )
virtual void
setSearchResolutionsOrder
( const std::vector< std::string > &  searchResolutionsOrder)
virtual

Sets the array that contains the search order of the resources.

Parameters
searchResolutionsOrderThe source array that contains the search order of the resources.
See also
getSearchResolutionsOrder(), fullPathForFilename(const char*).
Since
v2.1 In js:var setSearchResolutionsOrder(var jsval)
var setSearchResolutionsOrder ( var  searchResolutionsOrder)
virtual

Sets the array that contains the search order of the resources.

Parameters
searchResolutionsOrderThe source array that contains the search order of the resources.
See also
getSearchResolutionsOrder(), fullPathForFilename(const char*).
Since
v2.1 In js:var setSearchResolutionsOrder(var jsval)
virtual void
addSearchResolutionsOrder
( const std::string &  order,
const bool  front = false 
)
virtual

Append search order of the resources.

See also
setSearchResolutionsOrder(), fullPathForFilename().
Since
v2.1
var addSearchResolutionsOrder ( var  order,
var  front = false 
)
virtual

Append search order of the resources.

See also
setSearchResolutionsOrder(), fullPathForFilename().
Since
v2.1
local addSearchResolutionsOrder ( local  order,
local  front = false 
)
virtual

Append search order of the resources.

See also
setSearchResolutionsOrder(), fullPathForFilename().
Since
v2.1
virtual const std::vector
<std::string>
& getSearchResolutionsOrder
( ) const
virtual

Gets the array that contains the search order of the resources.

See also
setSearchResolutionsOrder(const std::vector<std::string>&), fullPathForFilename(const char*).
Since
v2.1
var getSearchResolutionsOrder ( )
virtual

Gets the array that contains the search order of the resources.

See also
setSearchResolutionsOrder(const std::vector<std::string>&), fullPathForFilename(const char*).
Since
v2.1
virtual void setSearchPaths ( const std::vector< std::string > &  searchPaths)
virtual

Sets the array of search paths.

You can use this array to modify the search path of the resources. If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array.

Note
This method could access relative path and absolute path. If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. For instance: On Android, the default resource root path is "assets/". If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, "resources-large" will be converted to "assets/resources-large" since it was a relative path.
Parameters
searchPathsThe array contains search paths.
See also
fullPathForFilename(const char*)
Since
v2.1 In js:var setSearchPaths(var jsval);
var setSearchPaths ( var  searchPaths)
virtual

Sets the array of search paths.

You can use this array to modify the search path of the resources. If you want to use "themes" or search resources in the "cache", you can do it easily by adding new entries in this array.

Note
This method could access relative path and absolute path. If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. For instance: On Android, the default resource root path is "assets/". If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, "resources-large" will be converted to "assets/resources-large" since it was a relative path.
Parameters
searchPathsThe array contains search paths.
See also
fullPathForFilename(const char*)
Since
v2.1 In js:var setSearchPaths(var jsval);
void addSearchPath ( const std::string &  path,
const bool  front = false 
)

Add search path.

Since
v2.1
var addSearchPath ( var  path,
var  front = false 
)

Add search path.

Since
v2.1
local addSearchPath ( local  path,
local  front = false 
)

Add search path.

Since
v2.1
virtual const std::vector
<std::string>& getSearchPaths
( ) const
virtual

Gets the array of search paths.

Returns
The array of search paths which may contain the prefix of default resource root path.
Note
In best practise, getter function should return the value of setter function passes in. But since we should not break the compatibility, we keep using the old logic. Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead.
See also
fullPathForFilename(const char*).
var getSearchPaths ( )
virtual

Gets the array of search paths.

Returns
The array of search paths which may contain the prefix of default resource root path.
Note
In best practise, getter function should return the value of setter function passes in. But since we should not break the compatibility, we keep using the old logic. Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead.
See also
fullPathForFilename(const char*).
virtual const std::vector
<std::string>
& getOriginalSearchPaths
( ) const
virtual

Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'.

Returns
The array of the original search paths
var getOriginalSearchPaths ( )
virtual

Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'.

Returns
The array of the original search paths
local getOriginalSearchPaths ( )
virtual

Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'.

Returns
The array of the original search paths
virtual std::string getWritablePath ( ) const
pure virtual

Gets the writable path.

Returns
The path that can be write/read a file in

Implemented in FileUtilsTizen.

var getWritablePath ( )
pure virtual

Gets the writable path.

Returns
The path that can be write/read a file in

Implemented in FileUtilsTizen.

local getWritablePath ( )
pure virtual

Gets the writable path.

Returns
The path that can be write/read a file in

Implemented in FileUtilsTizen.

virtual bool isPopupNotify ( ) const
virtual

Checks whether to pop up a message box when failed to load an image.

Returns
True if pop up a message box when failed to load an image, false if not.
var isPopupNotify ( )
virtual

Checks whether to pop up a message box when failed to load an image.

Returns
True if pop up a message box when failed to load an image, false if not.
local isPopupNotify ( )
virtual

Checks whether to pop up a message box when failed to load an image.

Returns
True if pop up a message box when failed to load an image, false if not.
virtual ValueMap
getValueMapFromFile
( const std::string &  filename)
virtual

Converts the contents of a file to a ValueMap.

Parameters
filenameThe filename of the file to gets content.
Returns
ValueMap of the file contents.
Note
This method is used internally.
var getValueMapFromFile ( var  filename)
virtual

Converts the contents of a file to a ValueMap.

Parameters
filenameThe filename of the file to gets content.
Returns
ValueMap of the file contents.
Note
This method is used internally.
local getValueMapFromFile ( local  filename)
virtual

Converts the contents of a file to a ValueMap.

Parameters
filenameThe filename of the file to gets content.
Returns
ValueMap of the file contents.
Note
This method is used internally.
virtual ValueMap
getValueMapFromData
( const char *  filedata,
int  filesize 
)
virtual

Converts the contents of a file to a ValueMap.

This method is used internally.

var getValueMapFromData ( var  filedata,
var  filesize 
)
virtual

Converts the contents of a file to a ValueMap.

This method is used internally.

local getValueMapFromData ( local  filedata,
local  filesize 
)
virtual

Converts the contents of a file to a ValueMap.

This method is used internally.

virtual bool writeToFile ( const ValueMap &  dict,
const std::string &  fullPath 
)
virtual

write a ValueMap into a plist file

Parameters
dictthe ValueMap want to save
fullPathThe full path to the file you want to save a string
Returns
bool
var writeToFile ( var  dict,
var  fullPath 
)
virtual

write a ValueMap into a plist file

Parameters
dictthe ValueMap want to save
fullPathThe full path to the file you want to save a string
Returns
bool
local writeToFile ( local  dict,
local  fullPath 
)
virtual

write a ValueMap into a plist file

Parameters
dictthe ValueMap want to save
fullPathThe full path to the file you want to save a string
Returns
bool
virtual bool writeStringToFile ( const std::string &  dataStr,
const std::string &  fullPath 
)
virtual

write a string into a file

Parameters
dataStrthe string want to save
fullPathThe full path to the file you want to save a string
Returns
bool True if write success
var writeStringToFile ( var  dataStr,
var  fullPath 
)
virtual

write a string into a file

Parameters
dataStrthe string want to save
fullPathThe full path to the file you want to save a string
Returns
bool True if write success
local writeStringToFile ( local  dataStr,
local  fullPath 
)
virtual

write a string into a file

Parameters
dataStrthe string want to save
fullPathThe full path to the file you want to save a string
Returns
bool True if write success
virtual void writeStringToFile ( std::string  dataStr,
const std::string &  fullPath,
std::function< void(bool)>  callback 
)
virtual

Write a string to a file, done async off the main cocos thread Use this function if you need file access without blocking the main thread.

This function takes a std::string by value on purpose, to leverage move sematics. If you want to avoid a copy of your datastr, use std::move/std::forward if appropriate

Parameters
dataStrthe string want to save
fullPathThe full path to the file you want to save a string
callbackThe function called once the string has been written to a file. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
var writeStringToFile ( var  dataStr,
var  fullPath,
var  callback 
)
virtual

Write a string to a file, done async off the main cocos thread Use this function if you need file access without blocking the main thread.

This function takes a std::string by value on purpose, to leverage move sematics. If you want to avoid a copy of your datastr, use std::move/std::forward if appropriate

Parameters
dataStrthe string want to save
fullPathThe full path to the file you want to save a string
callbackThe function called once the string has been written to a file. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
local writeStringToFile ( local  dataStr,
local  fullPath,
local  callback 
)
virtual

Write a string to a file, done async off the main cocos thread Use this function if you need file access without blocking the main thread.

This function takes a std::string by value on purpose, to leverage move sematics. If you want to avoid a copy of your datastr, use std::move/std::forward if appropriate

Parameters
dataStrthe string want to save
fullPathThe full path to the file you want to save a string
callbackThe function called once the string has been written to a file. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
virtual bool writeDataToFile ( const Data &  data,
const std::string &  fullPath 
)
virtual

write Data into a file

Parameters
datathe data want to save
fullPathThe full path to the file you want to save a string
Returns
bool
var writeDataToFile ( var  data,
var  fullPath 
)
virtual

write Data into a file

Parameters
datathe data want to save
fullPathThe full path to the file you want to save a string
Returns
bool
local writeDataToFile ( local  data,
local  fullPath 
)
virtual

write Data into a file

Parameters
datathe data want to save
fullPathThe full path to the file you want to save a string
Returns
bool
virtual void writeDataToFile ( Data  data,
const std::string &  fullPath,
std::function< void(bool)>  callback 
)
virtual

Write Data into a file, done async off the main cocos thread.

Use this function if you need to write Data while not blocking the main cocos thread.

This function takes Data by value on purpose, to leverage move sematics. If you want to avoid a copy of your data, use std::move/std::forward if appropriate

Parameters
dataThe data that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when data is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
var writeDataToFile ( var  data,
var  fullPath,
var  callback 
)
virtual

Write Data into a file, done async off the main cocos thread.

Use this function if you need to write Data while not blocking the main cocos thread.

This function takes Data by value on purpose, to leverage move sematics. If you want to avoid a copy of your data, use std::move/std::forward if appropriate

Parameters
dataThe data that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when data is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
local writeDataToFile ( local  data,
local  fullPath,
local  callback 
)
virtual

Write Data into a file, done async off the main cocos thread.

Use this function if you need to write Data while not blocking the main cocos thread.

This function takes Data by value on purpose, to leverage move sematics. If you want to avoid a copy of your data, use std::move/std::forward if appropriate

Parameters
dataThe data that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when data is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
virtual bool writeValueMapToFile ( const ValueMap &  dict,
const std::string &  fullPath 
)
virtual

write ValueMap into a plist file

Parameters
dictthe ValueMap want to save
fullPathThe full path to the file you want to save a string
Returns
bool
var writeValueMapToFile ( var  dict,
var  fullPath 
)
virtual

write ValueMap into a plist file

Parameters
dictthe ValueMap want to save
fullPathThe full path to the file you want to save a string
Returns
bool
local writeValueMapToFile ( local  dict,
local  fullPath 
)
virtual

write ValueMap into a plist file

Parameters
dictthe ValueMap want to save
fullPathThe full path to the file you want to save a string
Returns
bool
virtual void writeValueMapToFile ( ValueMap  dict,
const std::string &  fullPath,
std::function< void(bool)>  callback 
)
virtual

Write a ValueMap into a file, done async off the main cocos thread.

Use this function if you need to write a ValueMap while not blocking the main cocos thread.

This function takes ValueMap by value on purpose, to leverage move sematics. If you want to avoid a copy of your dict, use std::move/std::forward if appropriate

Parameters
dictThe ValueMap that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when dict is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
var writeValueMapToFile ( var  dict,
var  fullPath,
var  callback 
)
virtual

Write a ValueMap into a file, done async off the main cocos thread.

Use this function if you need to write a ValueMap while not blocking the main cocos thread.

This function takes ValueMap by value on purpose, to leverage move sematics. If you want to avoid a copy of your dict, use std::move/std::forward if appropriate

Parameters
dictThe ValueMap that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when dict is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
local writeValueMapToFile ( local  dict,
local  fullPath,
local  callback 
)
virtual

Write a ValueMap into a file, done async off the main cocos thread.

Use this function if you need to write a ValueMap while not blocking the main cocos thread.

This function takes ValueMap by value on purpose, to leverage move sematics. If you want to avoid a copy of your dict, use std::move/std::forward if appropriate

Parameters
dictThe ValueMap that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when dict is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
virtual bool writeValueVectorToFile ( const ValueVector &  vecData,
const std::string &  fullPath 
)
virtual

write ValueVector into a plist file

Parameters
vecDatathe ValueVector want to save
fullPathThe full path to the file you want to save a string
Returns
bool
var writeValueVectorToFile ( var  vecData,
var  fullPath 
)
virtual

write ValueVector into a plist file

Parameters
vecDatathe ValueVector want to save
fullPathThe full path to the file you want to save a string
Returns
bool
local writeValueVectorToFile ( local  vecData,
local  fullPath 
)
virtual

write ValueVector into a plist file

Parameters
vecDatathe ValueVector want to save
fullPathThe full path to the file you want to save a string
Returns
bool
virtual void writeValueVectorToFile ( ValueVector  vecData,
const std::string &  fullPath,
std::function< void(bool)>  callback 
)
virtual

Write a ValueVector into a file, done async off the main cocos thread.

Use this function if you need to write a ValueVector while not blocking the main cocos thread.

This function takes ValueVector by value on purpose, to leverage move sematics. If you want to avoid a copy of your dict, use std::move/std::forward if appropriate

Parameters
vecDataThe ValueVector that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when vecData is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
var writeValueVectorToFile ( var  vecData,
var  fullPath,
var  callback 
)
virtual

Write a ValueVector into a file, done async off the main cocos thread.

Use this function if you need to write a ValueVector while not blocking the main cocos thread.

This function takes ValueVector by value on purpose, to leverage move sematics. If you want to avoid a copy of your dict, use std::move/std::forward if appropriate

Parameters
vecDataThe ValueVector that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when vecData is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
local writeValueVectorToFile ( local  vecData,
local  fullPath,
local  callback 
)
virtual

Write a ValueVector into a file, done async off the main cocos thread.

Use this function if you need to write a ValueVector while not blocking the main cocos thread.

This function takes ValueVector by value on purpose, to leverage move sematics. If you want to avoid a copy of your dict, use std::move/std::forward if appropriate

Parameters
vecDataThe ValueVector that will be written to disk
fullPathThe absolute file path that the data will be written to
callbackThe function that will be called when vecData is written to disk. This function will be executed on the main cocos thread. It will have on boolean argument signifying if the write was successful.
virtual std::string
getSuitableFOpen
( const std::string &  filenameUtf8) const
virtual

Windows fopen can't support UTF-8 filename Need convert all parameters fopen and other 3rd-party libs.

Parameters
filenameUtf8std::string name file for conversion from utf-8
Returns
std::string ansi filename in current locale
var getSuitableFOpen ( var  filenameUtf8)
virtual

Windows fopen can't support UTF-8 filename Need convert all parameters fopen and other 3rd-party libs.

Parameters
filenameUtf8std::string name file for conversion from utf-8
Returns
std::string ansi filename in current locale
local getSuitableFOpen ( local  filenameUtf8)
virtual

Windows fopen can't support UTF-8 filename Need convert all parameters fopen and other 3rd-party libs.

Parameters
filenameUtf8std::string name file for conversion from utf-8
Returns
std::string ansi filename in current locale
virtual bool isFileExist ( const std::string &  filename) const
virtual

Checks whether a file exists.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filenameThe path of the file, it could be a relative or absolute path.
Returns
True if the file exists, false if not.
var isFileExist ( var  filename)
virtual

Checks whether a file exists.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filenameThe path of the file, it could be a relative or absolute path.
Returns
True if the file exists, false if not.
local isFileExist ( local  filename)
virtual

Checks whether a file exists.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filenameThe path of the file, it could be a relative or absolute path.
Returns
True if the file exists, false if not.
virtual void isFileExist ( const std::string &  filename,
std::function< void(bool)>  callback 
)
virtual

Checks if a file exists, done async off the main cocos thread.

Use this function if you need to check if a file exists while not blocking the main cocos thread.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filenameThe path of the file, it could be a relative or absolute path.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file exists, false otherwise.
var isFileExist ( var  filename,
var  callback 
)
virtual

Checks if a file exists, done async off the main cocos thread.

Use this function if you need to check if a file exists while not blocking the main cocos thread.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filenameThe path of the file, it could be a relative or absolute path.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file exists, false otherwise.
local isFileExist ( local  filename,
local  callback 
)
virtual

Checks if a file exists, done async off the main cocos thread.

Use this function if you need to check if a file exists while not blocking the main cocos thread.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filenameThe path of the file, it could be a relative or absolute path.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file exists, false otherwise.
virtual std::string
getFileExtension
( const std::string &  filePath) const
virtual

Gets filename extension is a suffix (separated from the base filename by a dot) in lower case.

Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt.

Parameters
filePathThe path of the file, it could be a relative or absolute path.
Returns
suffix for filename in lower case or empty if a dot not found.
var getFileExtension ( var  filePath)
virtual

Gets filename extension is a suffix (separated from the base filename by a dot) in lower case.

Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt.

Parameters
filePathThe path of the file, it could be a relative or absolute path.
Returns
suffix for filename in lower case or empty if a dot not found.
local getFileExtension ( local  filePath)
virtual

Gets filename extension is a suffix (separated from the base filename by a dot) in lower case.

Examples of filename extensions are .png, .jpeg, .exe, .dmg and .txt.

Parameters
filePathThe path of the file, it could be a relative or absolute path.
Returns
suffix for filename in lower case or empty if a dot not found.
virtual bool isAbsolutePath ( const std::string &  path) const
virtual

Checks whether the path is an absolute path.

Note
On Android, if the parameter passed in is relative to "assets/", this method will treat it as an absolute path. Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path.
Parameters
pathThe path that needs to be checked.
Returns
True if it's an absolute path, false if not.
var isAbsolutePath ( var  path)
virtual

Checks whether the path is an absolute path.

Note
On Android, if the parameter passed in is relative to "assets/", this method will treat it as an absolute path. Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path.
Parameters
pathThe path that needs to be checked.
Returns
True if it's an absolute path, false if not.
local isAbsolutePath ( local  path)
virtual

Checks whether the path is an absolute path.

Note
On Android, if the parameter passed in is relative to "assets/", this method will treat it as an absolute path. Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path.
Parameters
pathThe path that needs to be checked.
Returns
True if it's an absolute path, false if not.
virtual bool isDirectoryExist ( const std::string &  dirPath) const
virtual

Checks whether the path is a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
True if the directory exists, false if not.
var isDirectoryExist ( var  dirPath)
virtual

Checks whether the path is a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
True if the directory exists, false if not.
local isDirectoryExist ( local  dirPath)
virtual

Checks whether the path is a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
True if the directory exists, false if not.
virtual void isDirectoryExist ( const std::string &  fullPath,
std::function< void(bool)>  callback 
)
virtual

Checks whether the absoulate path is a directory, async off of the main cocos thread.

Parameters
dirPathThe path of the directory, it must be an absolute path
callbackthat will accept a boolean, true if the file exists, false otherwise. Callback will happen on the main cocos thread.
var isDirectoryExist ( var  fullPath,
var  callback 
)
virtual

Checks whether the absoulate path is a directory, async off of the main cocos thread.

Parameters
dirPathThe path of the directory, it must be an absolute path
callbackthat will accept a boolean, true if the file exists, false otherwise. Callback will happen on the main cocos thread.
local isDirectoryExist ( local  fullPath,
local  callback 
)
virtual

Checks whether the absoulate path is a directory, async off of the main cocos thread.

Parameters
dirPathThe path of the directory, it must be an absolute path
callbackthat will accept a boolean, true if the file exists, false otherwise. Callback will happen on the main cocos thread.
virtual bool createDirectory ( const std::string &  dirPath)
virtual

Creates a directory.

Parameters
dirPathThe path of the directory, it must be an absolute path.
Returns
True if the directory have been created successfully, false if not.
var createDirectory ( var  dirPath)
virtual

Creates a directory.

Parameters
dirPathThe path of the directory, it must be an absolute path.
Returns
True if the directory have been created successfully, false if not.
local createDirectory ( local  dirPath)
virtual

Creates a directory.

Parameters
dirPathThe path of the directory, it must be an absolute path.
Returns
True if the directory have been created successfully, false if not.
virtual void createDirectory ( const std::string &  dirPath,
std::function< void(bool)>  callback 
)
virtual

Create a directory, async off the main cocos thread.

Parameters
dirPaththe path of the directory, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the directory was successfully, false otherwise.
var createDirectory ( var  dirPath,
var  callback 
)
virtual

Create a directory, async off the main cocos thread.

Parameters
dirPaththe path of the directory, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the directory was successfully, false otherwise.
local createDirectory ( local  dirPath,
local  callback 
)
virtual

Create a directory, async off the main cocos thread.

Parameters
dirPaththe path of the directory, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the directory was successfully, false otherwise.
virtual bool removeDirectory ( const std::string &  dirPath)
virtual

Removes a directory.

Parameters
dirPathThe full path of the directory, it must be an absolute path.
Returns
True if the directory have been removed successfully, false if not.
var removeDirectory ( var  dirPath)
virtual

Removes a directory.

Parameters
dirPathThe full path of the directory, it must be an absolute path.
Returns
True if the directory have been removed successfully, false if not.
local removeDirectory ( local  dirPath)
virtual

Removes a directory.

Parameters
dirPathThe full path of the directory, it must be an absolute path.
Returns
True if the directory have been removed successfully, false if not.
virtual void removeDirectory ( const std::string &  dirPath,
std::function< void(bool)>  callback 
)
virtual

Removes a directory, async off the main cocos thread.

Parameters
dirPaththe path of the directory, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the directory was successfully removed, false otherwise.
var removeDirectory ( var  dirPath,
var  callback 
)
virtual

Removes a directory, async off the main cocos thread.

Parameters
dirPaththe path of the directory, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the directory was successfully removed, false otherwise.
local removeDirectory ( local  dirPath,
local  callback 
)
virtual

Removes a directory, async off the main cocos thread.

Parameters
dirPaththe path of the directory, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the directory was successfully removed, false otherwise.
virtual bool removeFile ( const std::string &  filepath)
virtual

Removes a file.

Parameters
filepathThe full path of the file, it must be an absolute path.
Returns
True if the file have been removed successfully, false if not.
var removeFile ( var  filepath)
virtual

Removes a file.

Parameters
filepathThe full path of the file, it must be an absolute path.
Returns
True if the file have been removed successfully, false if not.
local removeFile ( local  filepath)
virtual

Removes a file.

Parameters
filepathThe full path of the file, it must be an absolute path.
Returns
True if the file have been removed successfully, false if not.
virtual void removeFile ( const std::string &  filepath,
std::function< void(bool)>  callback 
)
virtual

Removes a file, async off the main cocos thread.

Parameters
filepaththe path of the file to remove, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully removed, false otherwise.
var removeFile ( var  filepath,
var  callback 
)
virtual

Removes a file, async off the main cocos thread.

Parameters
filepaththe path of the file to remove, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully removed, false otherwise.
local removeFile ( local  filepath,
local  callback 
)
virtual

Removes a file, async off the main cocos thread.

Parameters
filepaththe path of the file to remove, it must be an absolute path
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully removed, false otherwise.
virtual bool renameFile ( const std::string &  path,
const std::string &  oldname,
const std::string &  name 
)
virtual

Renames a file under the given directory.

Parameters
pathThe parent directory path of the file, it must be an absolute path.
oldnameThe current name of the file.
nameThe new name of the file.
Returns
True if the file have been renamed successfully, false if not.
var renameFile ( var  path,
var  oldname,
var  name 
)
virtual

Renames a file under the given directory.

Parameters
pathThe parent directory path of the file, it must be an absolute path.
oldnameThe current name of the file.
nameThe new name of the file.
Returns
True if the file have been renamed successfully, false if not.
local renameFile ( local  path,
local  oldname,
local  name 
)
virtual

Renames a file under the given directory.

Parameters
pathThe parent directory path of the file, it must be an absolute path.
oldnameThe current name of the file.
nameThe new name of the file.
Returns
True if the file have been renamed successfully, false if not.
virtual void renameFile ( const std::string &  path,
const std::string &  oldname,
const std::string &  name,
std::function< void(bool)>  callback 
)
virtual

Renames a file under the given directory, async off the main cocos thread.

Parameters
pathThe parent directory path of the file, it must be an absolute path.
oldnameThe current name of the file.
nameThe new name of the file.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully renamed, false otherwise.
var renameFile ( var  path,
var  oldname,
var  name,
var  callback 
)
virtual

Renames a file under the given directory, async off the main cocos thread.

Parameters
pathThe parent directory path of the file, it must be an absolute path.
oldnameThe current name of the file.
nameThe new name of the file.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully renamed, false otherwise.
local renameFile ( local  path,
local  oldname,
local  name,
local  callback 
)
virtual

Renames a file under the given directory, async off the main cocos thread.

Parameters
pathThe parent directory path of the file, it must be an absolute path.
oldnameThe current name of the file.
nameThe new name of the file.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully renamed, false otherwise.
virtual bool renameFile ( const std::string &  oldfullpath,
const std::string &  newfullpath 
)
virtual

Renames a file under the given directory.

Parameters
oldfullpathThe current fullpath of the file. Includes path and name.
newfullpathThe new fullpath of the file. Includes path and name.
Returns
True if the file have been renamed successfully, false if not.
var renameFile ( var  oldfullpath,
var  newfullpath 
)
virtual

Renames a file under the given directory.

Parameters
oldfullpathThe current fullpath of the file. Includes path and name.
newfullpathThe new fullpath of the file. Includes path and name.
Returns
True if the file have been renamed successfully, false if not.
local renameFile ( local  oldfullpath,
local  newfullpath 
)
virtual

Renames a file under the given directory.

Parameters
oldfullpathThe current fullpath of the file. Includes path and name.
newfullpathThe new fullpath of the file. Includes path and name.
Returns
True if the file have been renamed successfully, false if not.
virtual void renameFile ( const std::string &  oldfullpath,
const std::string &  newfullpath,
std::function< void(bool)>  callback 
)
virtual

Renames a file under the given directory, async off the main cocos thread.

Parameters
oldfullpathThe current fullpath of the file. Includes path and name.
newfullpathThe new fullpath of the file. Includes path and name.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully renamed, false otherwise.
var renameFile ( var  oldfullpath,
var  newfullpath,
var  callback 
)
virtual

Renames a file under the given directory, async off the main cocos thread.

Parameters
oldfullpathThe current fullpath of the file. Includes path and name.
newfullpathThe new fullpath of the file. Includes path and name.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully renamed, false otherwise.
local renameFile ( local  oldfullpath,
local  newfullpath,
local  callback 
)
virtual

Renames a file under the given directory, async off the main cocos thread.

Parameters
oldfullpathThe current fullpath of the file. Includes path and name.
newfullpathThe new fullpath of the file. Includes path and name.
callbackThe function that will be called when the operation is complete. Will have one boolean argument, true if the file was successfully renamed, false otherwise.
virtual long getFileSize ( const std::string &  filepath)
virtual

Retrieve the file size.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filepathThe path of the file, it could be a relative or absolute path.
Returns
The file size.
var getFileSize ( var  filepath)
virtual

Retrieve the file size.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filepathThe path of the file, it could be a relative or absolute path.
Returns
The file size.
local getFileSize ( local  filepath)
virtual

Retrieve the file size.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filepathThe path of the file, it could be a relative or absolute path.
Returns
The file size.
virtual void getFileSize ( const std::string &  filepath,
std::function< void(long)>  callback 
)
virtual

Retrieve the file size, async off the main cocos thread.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filepathThe path of the file, it could be a relative or absolute path.
callbackThe function that will be called when the operation is complete. Will have one long argument, the file size.
var getFileSize ( var  filepath,
var  callback 
)
virtual

Retrieve the file size, async off the main cocos thread.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filepathThe path of the file, it could be a relative or absolute path.
callbackThe function that will be called when the operation is complete. Will have one long argument, the file size.
local getFileSize ( local  filepath,
local  callback 
)
virtual

Retrieve the file size, async off the main cocos thread.

Note
If a relative path was passed in, it will be inserted a default root path at the beginning.
Parameters
filepathThe path of the file, it could be a relative or absolute path.
callbackThe function that will be called when the operation is complete. Will have one long argument, the file size.
virtual std::vector
<std::string> listFiles
( const std::string &  dirPath) const
virtual

List all files in a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
File paths in a string vector
var listFiles ( var  dirPath)
virtual

List all files in a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
File paths in a string vector
local listFiles ( local  dirPath)
virtual

List all files in a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
File paths in a string vector
virtual void listFilesAsync ( const std::string &  dirPath,
std::function< void(std::vector< std::string >)>  callback 
) const
virtual

List all files in a directory async, off of the main cocos thread.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
callbackThe callback to be called once the list operation is complete. Will be called on the main cocos thread.
virtual void listFilesRecursively ( const std::string &  dirPath,
std::vector< std::string > *  files 
) const
virtual

List all files recursively in a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
File paths in a string vector
var listFilesRecursively ( var  dirPath,
var  files 
)
virtual

List all files recursively in a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
File paths in a string vector
local listFilesRecursively ( local  dirPath,
local  files 
)
virtual

List all files recursively in a directory.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
Returns
File paths in a string vector
virtual void
listFilesRecursivelyAsync
( const std::string &  dirPath,
std::function< void(std::vector< std::string >)>  callback 
) const
virtual

List all files recursively in a directory, async off the main cocos thread.

Parameters
dirPathThe path of the directory, it could be a relative or an absolute path.
callbackThe callback to be called once the list operation is complete. Will be called on the main cocos thread.
const std::unordered_map
<std::string, std::string>
& getFullPathCache
( ) const
inline

Returns the full path cache.

var getFullPathCache ( )
inline

Returns the full path cache.

local getFullPathCache ( )
inline

Returns the full path cache.

virtual std::string getNewFilename ( const std::string &  filename) const
virtual

Gets the new filename from the filename lookup dictionary.

It is possible to have a override names.

Parameters
filenameThe original filename.
Returns
The new filename after searching in the filename lookup dictionary. If the original filename wasn't in the dictionary, it will return the original filename.
var getNewFilename ( var  filename)
virtual

Gets the new filename from the filename lookup dictionary.

It is possible to have a override names.

Parameters
filenameThe original filename.
Returns
The new filename after searching in the filename lookup dictionary. If the original filename wasn't in the dictionary, it will return the original filename.
local getNewFilename ( local  filename)
virtual

Gets the new filename from the filename lookup dictionary.

It is possible to have a override names.

Parameters
filenameThe original filename.
Returns
The new filename after searching in the filename lookup dictionary. If the original filename wasn't in the dictionary, it will return the original filename.

The documentation for this class was generated from the following file: