CCFileUtils
CCFileUtils
Cocos2DHelper class to handle file operations
Inheritance: System.Object
Constructors
CCFileUtils()
CCFileUtils()()
Fields
Properties
Set/Get whether pop-up a message box when the image load failed
Methods
CCLoadFileIntoMemory(string, out char[])
System.Int32 CCLoadFileIntoMemory(string, out char[])(System.String filename, System.Char[] file)
Parameters:
filename
(System.String)file
(System.Char[])Returns:
System.Int32
CCRemoveHDSuffixFromFile(string)
System.String CCRemoveHDSuffixFromFile(string)(System.String path)
removes the HD suffix from a path @returns const char * without the HD suffix @since v0.99.5
Parameters:
path
(System.String)Returns:
System.String
Example
DictionaryWithContentsOfFile(string)
System.Collections.Generic.DictionarySystem.String,System.Object DictionaryWithContentsOfFile(string)(System.String pFileName)
@brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file
Parameters:
pFileName
(System.String)Returns:
System.Collections.Generic.DictionarySystem.String,System.Object
Example
FullPathFromRelativeFile(string, string)
System.String FullPathFromRelativeFile(string, string)(System.String pszFilename, System.String pszRelativeFile)
extracts the directory from the pszRelativeFile and uses that directory path as the path for the pszFilename.
Parameters:
pszFilename
(System.String)pszRelativeFile
(System.String)Returns:
System.String
Example
FullPathFromRelativePath(string)
System.String FullPathFromRelativePath(string)(System.String pszRelativePath)
@brief Generate the absolute path of the file. @param pszRelativePath The relative path of the file. @return The absolute path of the file. @warning We only add the ResourcePath before the relative path of the file. If you have not set the ResourcePath,the function add "/NEWPLUS/TDA_DATA/UserData/" as default. You can set ResourcePath by function void setResourcePath(const char *pszResourcePath);
Parameters:
pszRelativePath
(System.String)Returns:
System.String
Example
GetFileBytes(string)
System.Byte[] GetFileBytes(string)(System.String pszFileName)
Parameters:
pszFileName
(System.String)Returns:
System.Byte[]
GetFileData(string)
System.String GetFileData(string)(System.String pszFileName)
@brief Get resource file data @param[in] pszFileName The resource file name which contain the path @param[in] pszMode The read mode of the file @param[out] pSize If get the file data succeed the it will be the data size,or it will be 0 @return if success,the pointer of data will be returned,or NULL is returned @warning If you get the file data succeed,you must delete it after used.
Parameters:
pszFileName
(System.String)Returns:
System.String
Example
GetFileDataFromZip(string, string, ulong)
System.Char[] GetFileDataFromZip(string, string, ulong)(System.String pszZipFilePath, System.String pszFileName, System.UInt64 pSize)
@brief Get resource file data from zip file @param[in] pszFileName The resource file name which contain the relative path of zip file @param[out] pSize If get the file data succeed the it will be the data size,or it will be 0 @return if success,the pointer of data will be returned,or NULL is returned @warning If you get the file data succeed,you must delete it after used.
Parameters:
pszZipFilePath
(System.String)pszFileName
(System.String)pSize
(System.UInt64)Returns:
System.Char[]
Example
GetFileStream(string)
System.IO.Stream GetFileStream(string)(System.String fileName)
Parameters:
fileName
(System.String)Returns:
System.IO.Stream
GetWriteablePath()
System.String GetWriteablePath()()
@brief Get the writeable path @return The path that can write/read file
Returns:
System.String
Example
RemoveExtension(string)
System.String RemoveExtension(string)(System.String fileName)
Parameters:
fileName
(System.String)Returns:
System.String
SetResource(string)
SetResource(string)(System.String pszZipFileName)
@brief Set the resource zip file name @param pszZipFileName The relative path of the .zip file
Parameters:
pszZipFileName
(System.String)Example
SetResourcePath(string)
SetResourcePath(string)(System.String pszResourcePath)
@brief Set the ResourcePath,we will find resource in this path @param pszResourcePath The absolute resource path @warning Don't call this function in android and iOS, it has not effect. In android, if you want to read file other than apk, you shoud use invoke getFileData(), and pass the absolute path.
Parameters:
pszResourcePath
(System.String)Example