Axmol Engine 2.4.0-258ceca
Loading...
Searching...
No Matches
FileUtilsWinRT Class Reference

Helper class to handle file operations. More...

#include <FileUtilsWinRT.h>

Inherits FileUtils.

Public Member Functions

bool init ()
 Initializes the instance of FileUtils.
 
virtual std::string getWritablePath () const
 Gets the writable path that may not be in the format of an absolute path.
 
virtual bool isAbsolutePath (std::string_view strPath) const override
 Checks whether the path is an absolute path.
 
virtual std::string getPathForFilename (std::string_view filename, std::string_view resolutionDirectory) const override
 Gets full path for filename, resolution directory and search path.
 
virtual std::string getFullPathForFilenameWithinDirectory (std::string_view strDirectory, std::string_view strFilename) const override
 Gets full path for the directory and the filename.
 
virtual int64_t getFileSize (std::string_view filepath) const override
 Retrieve the file size.
 
std::string getNativeWritableAbsolutePath () const override
 Gets the writable path in the native file-system format.
 
- Public Member Functions inherited from FileUtils
virtual ~FileUtils ()
 The destructor of FileUtils.
 
virtual void purgeCachedEntries ()
 Purges full path caches.
 
virtual std::string getStringFromFile (std::string_view filename) const
 Gets string from a file.
 
virtual Data getDataFromFile (std::string_view filename) const
 Creates binary data from a file.
 
template<typename T, typename Enable = std::enable_if_t<is_resizable_container_v<T>>>
Status getContents (std::string_view filename, T *buffer) const
 Gets whole file contents as string from a file.
 
virtual std::string fullPathForFilename (std::string_view filename) const
 Returns the fullpath for a given filename.
 
virtual std::string fullPathFromRelativeFile (std::string_view filename, std::string_view relativeFile) const
 Gets full path from a file name and the path of the relative file.
 
virtual std::string fullPathForDirectory (std::string_view dirname) const
 Returns the fullpath for a given dirname.
 
virtual void setSearchPaths (const std::vector< std::string > &searchPaths)
 Sets the array of search paths.
 
const std::string & getDefaultResourceRootPath () const
 Get default resource root path.
 
void setDefaultResourceRootPath (std::string_view path)
 Set default resource root path.
 
void addSearchPath (std::string_view path, const bool front=false)
 Add search path.
 
virtual const std::vector< std::string > & getSearchPaths () const
 Gets the array of search paths.
 
virtual const std::vector< std::string > & getOriginalSearchPaths () const
 Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'.
 
virtual void setWritablePath (std::string_view 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.
 
virtual ValueMap getValueMapFromFile (std::string_view filename) const
 Converts the contents of a file to a ValueMap.
 
virtual ValueMap getValueMapFromData (const char *filedata, int filesize) const
 Converts the contents of a file to a ValueMap.
 
virtual bool writeToFile (const ValueMap &dict, std::string_view fullPath) const
 write a ValueMap into a plist file
 
virtual bool writeStringToFile (std::string_view dataStr, std::string_view fullPath) const
 write a string into a file
 
virtual bool writeDataToFile (const Data &data, std::string_view fullPath) const
 write Data into a file
 
virtual bool writeValueMapToFile (const ValueMap &dict, std::string_view fullPath) const
 write ValueMap into a plist file
 
virtual bool writeValueVectorToFile (const ValueVector &vecData, std::string_view fullPath) const
 write ValueVector into a plist file
 
virtual bool isFileExist (std::string_view filename) const
 Checks whether a file exists.
 
virtual bool isDirectoryExist (std::string_view dirPath) const
 Checks whether the path is a directory.
 
virtual std::vector< std::string > listFiles (std::string_view dirPath) const
 List all files in a directory.
 
virtual void listFilesRecursively (std::string_view dirPath, std::vector< std::string > *files) const
 List all files recursively in a directory.
 
AX_DEPRECATED(2.1) virtual void getStringFromFile(std AX_DEPRECATED(2.1) virtual void getDataFromFile(std AX_DEPRECATED(2.1) virtual void writeStringToFile(std AX_DEPRECATED (2.1) virtual void writeDataToFile(Data data
 Gets string from a file, async off the main cocos thread.
 
 AX_DEPRECATED (2.1) virtual void writeValueMapToFile(ValueMap dict
 Write a ValueMap into a file, done async off the main cocos thread.
 
 AX_DEPRECATED (2.1) virtual void writeValueVectorToFile(ValueVector vecData
 Write a ValueVector into a file, done async off the main cocos thread.
 
AX_DEPRECATED(2.1) virtual void isFileExist(std AX_DEPRECATED (2.1) static std
 Checks if a file exists, done async off the main cocos thread.
 
AX_DEPRECATED(2.1) virtual void isDirectoryExist(std AX_DEPRECATED(2.1) bool createDirectory(std AX_DEPRECATED(2.1) void removeDirectory(std AX_DEPRECATED(2.1) virtual void removeFile(std AX_DEPRECATED(2.1) virtual void renameFile(std AX_DEPRECATED(2.1) void renameFile(std AX_DEPRECATED(2.1) void getFileSize(std AX_DEPRECATED(2.1) void listFilesAsync(std AX_DEPRECATED(2.1) void listFilesRecursivelyAsync(std const hlookup::string_map< std::string > getFullPathCache () const
 Checks whether the absoulate path is a directory, async off of the main cocos thread.
 
const hlookup::string_map< std::string > getFullPathCacheDir () const
 Returns the full path cache.
 
virtual std::unique_ptr< IFileStream > openFileStream (std::string_view filePath, IFileStream::Mode mode) const
 Open a FileStream based on the implementation provided in openFileStream or its overrides.
 

Additional Inherited Members

- Static Public Member Functions inherited from FileUtils
static FileUtilsgetInstance ()
 Gets the instance of FileUtils.
 
static void 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.
 
static bool writeBinaryToFile (const void *data, size_t dataSize, std::string_view fullPath)
 save data to file
 
static std::string getPathExtension (std::string_view filePath)
 Gets filename extension is a suffix (separated from the base filename by a dot) in lower case.
 

Detailed Description

Helper class to handle file operations.

Member Function Documentation

◆ init()

bool init ( )
virtual

Initializes the instance of FileUtils.

It will set _searchPathArray. values.

Note
When you are porting Cocos2d-x to a new platform, you may need to take care of this method. You could assign a default value to _defaultResRootPath in the subclass of FileUtils(e.g. FileUtilsAndroid). Then invoke the FileUtils::init().
Returns
true if succeed, otherwise it returns false.

Reimplemented from FileUtils.

◆ getWritablePath()

virtual std::string getWritablePath ( ) const
virtual

Gets the writable path that may not be in the format of an absolute path.

Returns
The path that can be write/read a file in
Note
This may return the same value as getNativeWritableAbsolutePath(). If you require the absolute path to the underlying file system, then call getNativeWritableAbsolutePath() instead.

Implements FileUtils.

◆ isAbsolutePath()

virtual bool isAbsolutePath ( std::string_view path) const
overridevirtual

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.

Reimplemented from FileUtils.

◆ getPathForFilename()

virtual std::string getPathForFilename ( std::string_view filename,
std::string_view searchPath ) const
overridevirtual

Gets full path for filename, resolution directory and search path.

Parameters
filenameThe file name.
searchPathThe search path.
Returns
The full path of the file. It will return an empty string if the full path of the file doesn't exist.

Reimplemented from FileUtils.

◆ getFullPathForFilenameWithinDirectory()

virtual std::string getFullPathForFilenameWithinDirectory ( std::string_view directory,
std::string_view filename ) const
overridevirtual

Gets full path for the directory and the filename.

Note
Only iOS and Mac need to override this method since they are using [[NSBundle mainBundle] pathForResource: ofType: inDirectory:] to make a full path. Other platforms will use the default implementation of this method.
Parameters
directoryThe directory contains the file we are looking for.
filenameThe name of the file.
Returns
The full path of the file, if the file can't be found, it will return an empty string.

Reimplemented from FileUtils.

◆ getFileSize()

virtual int64_t getFileSize ( std::string_view filepath) const
overridevirtual

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.

Reimplemented from FileUtils.

◆ getNativeWritableAbsolutePath()

std::string getNativeWritableAbsolutePath ( ) const
overridevirtual

Gets the writable path in the native file-system format.

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

Implements FileUtils.


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