-
Notifications
You must be signed in to change notification settings - Fork 1
Storage
This is a module for managing cloud storage files.
This module offers a collection of functions designed to address specific tasks and provide utilities for various purposes. Explore the available functions to make the most of the functionalities provided by this module.
- GOG_Storage_DownloadSharedFile
- GOG_Storage_FileDelete
- GOG_Storage_FileExists
- GOG_Storage_FileRead
- GOG_Storage_FileShare
- GOG_Storage_FileWrite
- GOG_Storage_GetDownloadedSharedFileByIndex
- GOG_Storage_GetDownloadedSharedFileCount
- GOG_Storage_GetFileCount
- GOG_Storage_GetFileNameByIndex
- GOG_Storage_GetFileSize
- GOG_Storage_GetFileTimestamp
- GOG_Storage_GetSharedFileName
- GOG_Storage_GetSharedFileOwner
- GOG_Storage_GetSharedFileSize
- GOG_Storage_SharedFileClose
- GOG_Storage_SharedFileRead
This function downloads a previously shared file. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Storage_DownloadSharedFile(sharedFileID)
Argument | Type | Description |
---|---|---|
sharedFileID | Int64 | The ID of the shared file. |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Storage_DownloadSharedFile" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
sharedFileID | String | The ID of the shared file. |
fileName | String | Name of the shared file |
Example:
GOG_Storage_DownloadSharedFile(sharedFileID);
The code sample above starts a task to download a shared file. The results can be caught inside a Social Async Event event.
if (async_load[? "type"] == "GOG_Storage_DownloadSharedFile")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
var _sharedFileID = async_load[?"sharedFileID"];
var _fileName = async_load[?"fileName"];
show_debug_message("DownloadSharedFile SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function deletes the given file.
Warning
REQUIREMENT The name that specifies the file has to be provided in the form of a relative path that uses slashes as separators. Every part of the path must not refer to any special or restricted name on any of the supported platforms. Backslashes are not allowed.
Syntax:
GOG_Storage_FileDelete(fileName)
Argument | Type | Description |
---|---|---|
fileName | String | The name of the file in the form of a path |
Returns:
N/A
Example:
GOG_Storage_FileDelete(fileName);
The code above provides a simple usage example.
This function returns if the given file exists.
Warning
REQUIREMENT The name that specifies the file has to be provided in the form of a relative path that uses slashes as separators. Every part of the path must not refer to any special or restricted name on any of the supported platforms. Backslashes are not allowed.
Syntax:
GOG_Storage_FileExists(fileName)
Argument | Type | Description |
---|---|---|
fileName | String | The name of the file in the form of a path |
Returns:
Example:
if(GOG_Storage_FileExists(fileName))
{
//File exists, do something
}
The code above provides a simple usage example.
This function reads file content into the buffer.
Warning
REQUIREMENT The name that specifies the file has to be provided in the form of a relative path that uses slashes as separators. Every part of the path must not refer to any special or restricted name on any of the supported platforms. Backslashes are not allowed.
Warning
This function creates a new buffer everytime it is called, unless a buffer is already specified. You need to ensure you correctly delete the buffer when you don't need it anymore using the buffer_delete function. Failing to do so will result in memory leaks.
Syntax:
GOG_Storage_FileRead(fileName, bufferID=undefined, byteOffset=undefined)
Argument | Type | Description |
---|---|---|
fileName | String | The name of the file in the form of a path |
bufferID | Buffer | OPTIONAL: use an existing buffer instead of allocating a new one |
byteOffset | Real | OPTIONAL: write data to a specific offset in the buffer |
Returns:
Example:
var _buffer = GOG_Storage_FileRead(fileName);
The code above provides a simple usage example.
This function uploads the file for sharing. This is an asynchronous function that will trigger a Social Async Event when the task is finished.
Warning
REQUIREMENT The name that specifies the file has to be provided in the form of a relative path that uses slashes as separators. Every part of the path must not refer to any special or restricted name on any of the supported platforms. Backslashes are not allowed.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.
Syntax:
GOG_Storage_FileShare(fileName)
Argument | Type | Description |
---|---|---|
fileName | String | The name of the file in the form of a path |
Returns:
N/A
Triggers:
Key | Type | Description |
---|---|---|
type | String | "GOG_Storage_FileShare" |
error | String | The error message; only if request failed ✴️ OPTIONAL |
sharedFileID | String | The ID of the shared file. |
fileName | String | Name of the shared file |
Example:
GOG_Storage_FileShare(fileName);
The code sample above starts a task for sharing a file, which results can be caught inside a Social Async Event event.
if (async_load[? "type"] == "GOG_Storage_FileShare")
{
if (ds_map_exists(async_load, "error"))
{
show_debug_message(async_load[?"error"]);
exit;
}
var _sharedFileID = async_load[?"sharedFileID"];
var _fileName = async_load[?"fileName"];
show_debug_message("FileShare SUCCESS");
}
This code sample provides an example of handling the returned callback data.
This function writes data into the file.
Warning
REQUIREMENT The name that specifies the file has to be provided in the form of a relative path that uses slashes as separators. Every part of the path must not refer to any special or restricted name on any of the supported platforms. Backslashes are not allowed.
Note
The files created using this method will be stored in GOG Galaxy internal directory and should be accessed only via Galaxy SDK methods.
Syntax:
GOG_Storage_FileWrite(fileName, buffer)
Argument | Type | Description |
---|---|---|
fileName | String | Name of the file |
buffer | Buffer | Buffer with data |
Returns:
N/A
Example:
GOG_Storage_FileWrite(fileName, buffer);
The code above provides a simple usage example.
This function returns the ID of the open downloaded shared file.
Syntax:
GOG_Storage_GetDownloadedSharedFileByIndex(index)
Argument | Type | Description |
---|---|---|
index | Real | Index as an integer in the range of [0, number of open downloaded shared files]. |
Returns:
Example:
for(var i = 0 ; i < GetDownloadedSharedFileCount() ; i++)
{
var _sharedFileID= GOG_Storage_GetDownloadedSharedFileByIndex(i);
var _fileName = GOG_Storage_GetSharedFileName(_sharedFileID);
var _fileSize = GOG_Storage_GetSharedFileSize(_sharedFileID);
var _owner = GOG_Storage_GetSharedFileOwner(_sharedFileID);
var _buffer = GOG_Storage_SharedFileRead(_sharedFileID);
}
The code above provides a simple usage example.
This function returns the number of open downloaded shared files.
Syntax:
GOG_Storage_GetDownloadedSharedFileCount()
Returns:
Example:
for(var i = 0 ; i < GetDownloadedSharedFileCount() ; i++)
{
var _sharedFileID = GOG_Storage_GetDownloadedSharedFileByIndex(i);
var _fileName = GOG_Storage_GetSharedFileName(_sharedFileID);
var _fileSize = GOG_Storage_GetSharedFileSize(_sharedFileID);
var _owner = GOG_Storage_GetSharedFileOwner(_sharedFileID);
var _buffer = GOG_Storage_SharedFileRead(_sharedFileID);
}
The code above provides a simple usage example.
This function returns the number of files in the storage.
Syntax:
GOG_Storage_GetFileCount()
Returns:
Example:
for(i = 0 ; i < GOG_Storage_GetFileCount() ; i++)
{
var _filename = GOG_Storage_GetFileNameByIndex(i);
var _fileSize = GOG_Storage_GetFileSize(_filename);
var _fileTimestamp = GOG_Storage_GetFileTimestamp(_filename);
var _fileSize = GOG_Storage_GetSharedFileSize(_filename);
}
The code above provides a simple usage example.
This function returns the name of the file.
Syntax:
GOG_Storage_GetFileNameByIndex(index)
Argument | Type | Description |
---|---|---|
index | Real | The index as an integer in the range of [0, number of files]. |
Returns:
Example:
for(i = 0 ; i < GOG_Storage_GetFileCount() ; i++)
{
var _filename = GOG_Storage_GetFileNameByIndex(i);
var _fileSize = GOG_Storage_GetFileSize(__filename);
var _fileTimestamp = GOG_Storage_GetFileTimestamp(_filename);
var _fileSize = GOG_Storage_GetSharedFileSize(_filename);
}
The code above provides a simple usage example.
This function returns the size of the file.
Warning
REQUIREMENT The name that specifies the file has to be provided in the form of a relative path that uses slashes as separators. Every part of the path must not refer to any special or restricted name on any of the supported platforms. Backslashes are not allowed.
Syntax:
GOG_Storage_GetFileSize(filename)
Argument | Type | Description |
---|---|---|
filename | String | The name of the file in the form of a path. |
Returns:
Example:
for(i = 0 ; i < GOG_Storage_GetFileCount() ; i++)
{
var _filename = GOG_Storage_GetFileNameByIndex(i);
var _fileSize = GOG_Storage_GetFileSize(_filename);
var _fileTimestamp = GOG_Storage_GetFileTimestamp(_filename);
var _fileSize = GOG_Storage_GetSharedFileSize(_filename);
}
The code above provides a simple usage example.
This function returns the timestamp of the last file modification.
Warning
REQUIREMENT The name that specifies the file has to be provided in the form of a relative path that uses slashes as separators. Every part of the path must not refer to any special or restricted name on any of the supported platforms. Backslashes are not allowed.
Syntax:
GOG_Storage_GetFileTimestamp(filename)
Argument | Type | Description |
---|---|---|
filename | String | The name of the file in the form of a path. |
Returns:
Example:
for(i = 0 ; i < GOG_Storage_GetFileCount() ; i++)
{
var _filename = GOG_Storage_GetFileNameByIndex(i);
var _fileSize = GOG_Storage_GetFileSize(_filename);
var _fileTimestamp = GOG_Storage_GetFileTimestamp(_filename);
var _fileSize = GOG_Storage_GetSharedFileSize(_filename);
}
The code above provides a simple usage example.
This function gets the name of a downloaded shared file.
Syntax:
GOG_Storage_GetSharedFileName(sharedFileID)
Argument | Type | Description |
---|---|---|
sharedFileID | Int64 | The ID of the shared file. |
Returns:
Example:
for(var i = 0 ; i < GetDownloadedSharedFileCount() ; i++)
{
var _sharedFileID = GOG_Storage_GetDownloadedSharedFileByIndex(i);
var _fileName = GOG_Storage_GetSharedFileName(_sharedFileID);
var _fileSize = GOG_Storage_GetSharedFileSize(_sharedFileID);
var _owner = GOG_Storage_GetSharedFileOwner(_sharedFileID);
var _buffer = GOG_Storage_SharedFileRead(_sharedFileID);
}
The code above provides a simple usage example.
This function gets the owner GalaxyID of a downloaded shared file.
Syntax:
GOG_Storage_GetSharedFileOwner(sharedFileID)
Argument | Type | Description |
---|---|---|
sharedFileID | Int64 | The ID of the shared file. |
Returns:
Example:
for(var i = 0 ; i < GetDownloadedSharedFileCount() ; i++)
{
var _sharedFileID = GOG_Storage_GetDownloadedSharedFileByIndex(i);
var _fileName = GOG_Storage_GetSharedFileName(sharedFileID);
var _fileSize = GOG_Storage_GetSharedFileSize(sharedFileID);
var _owner = GOG_Storage_GetSharedFileOwner(sharedFileID);
var _buffer = GOG_Storage_SharedFileRead(sharedFileID);
}
The code above provides a simple usage example.
This function gets the size of a downloaded shared file.
Syntax:
GOG_Storage_GetSharedFileSize(sharedFileID)
Argument | Type | Description |
---|---|---|
sharedFileID | Int64 | The ID of the shared file. |
Returns:
Example:
for(var i = 0 ; i < GetDownloadedSharedFileCount() ; i++)
{
var _sharedFileID = GOG_Storage_GetDownloadedSharedFileByIndex(i);
var _fileName = GOG_Storage_GetSharedFileName(_sharedFileID);
var _fileSize = GOG_Storage_GetSharedFileSize(_sharedFileID);
var _owner = GOG_Storage_GetSharedFileOwner(_sharedFileID);
var _buffer = GOG_Storage_SharedFileRead(_sharedFileID);
}
The code above provides a simple usage example.
This function closes the given downloaded shared file and frees the memory.
Syntax:
GOG_Storage_SharedFileClose(sharedFileID)
Argument | Type | Description |
---|---|---|
sharedFileID | Int64 | The ID of the shared file. |
Returns:
N/A
Example:
GOG_Storage_SharedFileClose(sharedFileID);
The code above provides a simple usage example.
This function reads the given downloaded shared file's contents into the buffer.
Warning
This function creates a new buffer everytime it is called, unless a buffer is already specified. You need to ensure you correctly delete the buffer when you don't need it anymore using the buffer_delete function. Failing to do so will result in memory leaks.
Syntax:
GOG_Storage_SharedFileRead(sharedFileID, bufferID=undefined, byteOffset=undefined)
Argument | Type | Description |
---|---|---|
sharedFileID | Int64 | The ID of the shared file. |
bufferID | Buffer | OPTIONAL: use an existing buffer instead of allocating a new one |
byteOffset | Real | OPTIONAL: write data to a specific offset in the buffer |
Returns:
Example:
for(var i = 0 ; i < GetDownloadedSharedFileCount() ; i++)
{
var _sharedFileID = GOG_Storage_GetDownloadedSharedFileByIndex(i);
var _fileName = GOG_Storage_GetSharedFileName(_sharedFileID);
var _fileSize = GOG_Storage_GetSharedFileSize(_sharedFileID);
var _owner = GOG_Storage_GetSharedFileOwner(_sharedFileID);
var _buffer = GOG_Storage_SharedFileRead(_sharedFileID);
}
The code above provides a simple usage example.
GameMaker 2024