mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-18 01:08:16 +00:00
Added SDL_CopyFile() and SDL_CopyStorageFile()
Fixes https://github.com/libsdl-org/SDL/issues/9553
This commit is contained in:
@@ -291,6 +291,24 @@ int SDL_RenameStoragePath(SDL_Storage *storage, const char *oldpath, const char
|
||||
return storage->iface.rename(storage->userdata, oldpath, newpath);
|
||||
}
|
||||
|
||||
int SDL_CopyStorageFile(SDL_Storage *storage, const char *oldpath, const char *newpath)
|
||||
{
|
||||
CHECK_STORAGE_MAGIC()
|
||||
|
||||
if (!oldpath) {
|
||||
return SDL_InvalidParamError("oldpath");
|
||||
}
|
||||
if (!newpath) {
|
||||
return SDL_InvalidParamError("newpath");
|
||||
}
|
||||
|
||||
if (!storage->iface.copy) {
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
return storage->iface.copy(storage->userdata, oldpath, newpath);
|
||||
}
|
||||
|
||||
int SDL_GetStoragePathInfo(SDL_Storage *storage, const char *path, SDL_PathInfo *info)
|
||||
{
|
||||
SDL_PathInfo dummy;
|
||||
|
@@ -160,6 +160,21 @@ static int GENERIC_RenameStoragePath(void *userdata, const char *oldpath, const
|
||||
return result;
|
||||
}
|
||||
|
||||
static int GENERIC_CopyStorageFile(void *userdata, const char *oldpath, const char *newpath)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
char *fulloldpath = GENERIC_INTERNAL_CreateFullPath((char *)userdata, oldpath);
|
||||
char *fullnewpath = GENERIC_INTERNAL_CreateFullPath((char *)userdata, newpath);
|
||||
if (fulloldpath && fullnewpath) {
|
||||
result = SDL_CopyFile(fulloldpath, fullnewpath);
|
||||
}
|
||||
SDL_free(fulloldpath);
|
||||
SDL_free(fullnewpath);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static Uint64 GENERIC_GetStorageSpaceRemaining(void *userdata)
|
||||
{
|
||||
/* TODO: There's totally a way to query a folder root's quota... */
|
||||
@@ -176,6 +191,7 @@ static const SDL_StorageInterface GENERIC_title_iface = {
|
||||
NULL, /* mkdir */
|
||||
NULL, /* remove */
|
||||
NULL, /* rename */
|
||||
NULL, /* copy */
|
||||
NULL /* space_remaining */
|
||||
};
|
||||
|
||||
@@ -219,6 +235,7 @@ static const SDL_StorageInterface GENERIC_user_iface = {
|
||||
GENERIC_CreateStorageDirectory,
|
||||
GENERIC_RemoveStoragePath,
|
||||
GENERIC_RenameStoragePath,
|
||||
GENERIC_CopyStorageFile,
|
||||
GENERIC_GetStorageSpaceRemaining
|
||||
};
|
||||
|
||||
@@ -257,6 +274,7 @@ static const SDL_StorageInterface GENERIC_file_iface = {
|
||||
GENERIC_CreateStorageDirectory,
|
||||
GENERIC_RemoveStoragePath,
|
||||
GENERIC_RenameStoragePath,
|
||||
GENERIC_CopyStorageFile,
|
||||
GENERIC_GetStorageSpaceRemaining
|
||||
};
|
||||
|
||||
|
@@ -140,6 +140,7 @@ static const SDL_StorageInterface STEAM_user_iface = {
|
||||
NULL, /* mkdir */
|
||||
NULL, /* remove */
|
||||
NULL, /* rename */
|
||||
NULL, /* copy */
|
||||
STEAM_GetStorageSpaceRemaining
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user