Class FileKit
FileKit used to download content for the game as you play or sit in a loading screen.
Inheritance
Namespace: Trail
Assembly: Trail.dll
Syntax
public static class FileKit : object
Methods
GetCloudStoragePath()
Returns the directory where to put files to be synchronized.
Declaration
public static string GetCloudStoragePath()
Returns
Type | Description |
---|---|
System.String | Returns the path to the directory (usually /trail/cloud_storage). |
GetCloudStoragePath(out String)
Returns the directory where to put files to be synchronized.
Declaration
public static Result GetCloudStoragePath(out string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Returns the path to the directory (usually /trail/cloud_storage). |
Returns
Type | Description |
---|---|
Result | If the operation was successful or not. |
GetCloudStoragePathFormatted(String)
Returns the directory where to put files to be synchronized.
Declaration
public static string GetCloudStoragePathFormatted(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName |
Returns
Type | Description |
---|---|
System.String | Returns the path to the directory with the file name in the path. Example /trail/cloud_storage/example.txt. |
GetFileSize(String)
Gets the size of the file at the specified file path.
Declaration
public static int GetFileSize(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | path to the file, e.g. StreamingAssets/myfile.json |
Returns
Type | Description |
---|---|
System.Int32 | Returns the size of the file at the file path or 0 if any errors. |
GetFileSize(String, out Int32)
Gets the size of the file at the specified file path.
Declaration
public static Result GetFileSize(string path, out int size)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | path to the file, e.g. StreamingAssets/myfile.json |
System.Int32 | size | output parameter giving the size of the file at the file path |
Returns
Type | Description |
---|---|
Result | Returns result whether succeedes or not. |
PreloadFile(String)
Preloads a file, making it available for reading later.
Declaration
public static Result PreloadFile(string filepath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filepath | The specified file path to preload |
Returns
Type | Description |
---|---|
Result | Returns whether able to preload the file or not. |
ReadFile(String)
Reads the file at the specified file path.
Declaration
public static FileKit.FileReadOperation ReadFile(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The specified path to read from. |
Returns
Type | Description |
---|---|
FileKit.FileReadOperation | Returns an file read operation for async code or coroutines. |
ReadFile(String, FileKit.FileReadComplete)
Reads the file at the specified file path.
Declaration
public static void ReadFile(string path, FileKit.FileReadComplete callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The specified path to read from. |
FileKit.FileReadComplete | callback | Callback for Filekit to call when file is read. |
ReadFileNonAlloc(String, Byte[])
Reads the file at the specified file path without allocating a new byte array.
Declaration
public static FileKit.FileReadOperation ReadFileNonAlloc(string path, byte[] data)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The specified path to read from. |
System.Byte[] | data | The byte buffer to load the file content into. |
Returns
Type | Description |
---|---|
FileKit.FileReadOperation | Returns an file read operation for async code or coroutines. |
ReadFileNonAlloc(String, Byte[], FileKit.FileReadComplete)
Reads the file at the specified file path without allocating a new byte array.
Declaration
public static void ReadFileNonAlloc(string path, byte[] data, FileKit.FileReadComplete callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The specified path to read from. |
System.Byte[] | data | The byte buffer to load the file content into. |
FileKit.FileReadComplete | callback | Callback for Filekit to call when file is read. |
StartFileQueue()
Start the download file queue
Declaration
public static Result StartFileQueue()
Returns
Type | Description |
---|---|
Result | If the operation was successful or not. |
StopFileQueue()
Stop the download file queue
Declaration
public static Result StopFileQueue()
Returns
Type | Description |
---|---|
Result | If the operation was successful or not. |
SyncCloudStorage(FileKit.SyncCloudStorageCallback)
Synchronize all files in the cloud storage directory.
Declaration
public static void SyncCloudStorage(FileKit.SyncCloudStorageCallback callback)
Parameters
Type | Name | Description |
---|---|---|
FileKit.SyncCloudStorageCallback | callback | Callback returning result of the synchronization. |