Exemplo n.º 1
0
// only for saves on sdcard
DECL(int, FSRenameAsync, void *pClient, void *pCmd, char *oldPath, char *newPath, int error, FSAsyncParams *asyncParams) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], oldPath, BYTE_RENAME);
        log_string(bss.socket_fs[client], newPath, BYTE_RENAME);

        // change path if it is a save folder
        if (is_savefile(oldPath)) {
            // old path
            int len_base = (strlen(bss.save_base) + 8);
            int len_old = strlen(oldPath);
            char new_old_path[len_old + len_base + 1];
            compute_new_path(new_old_path, oldPath, len_old, 1);

            // new path
            int len_new = strlen(newPath);
            char new_new_path[len_new + len_base + 1];
            compute_new_path(new_new_path, newPath, len_new, 1);

            // log new path
            log_string(bss.socket_fs[client], new_old_path, BYTE_LOG_STR);
            log_string(bss.socket_fs[client], new_new_path, BYTE_LOG_STR);

            return real_FSRenameAsync(pClient, pCmd, new_old_path, new_new_path, error, asyncParams);
        }
    }
    return real_FSRenameAsync(pClient, pCmd, oldPath, newPath, error, asyncParams);
}
Exemplo n.º 2
0
DECL(int, FSChangeDirAsync, void *pClient, void *pCmd, char *path, int error, FSAsyncParams *asyncParams) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], path, BYTE_CHANGE_DIR_ASYNC);

        // change path if it is a game folder
        int is_save = 0;
        if (is_gamefile(path) || (is_save = is_savefile(path))) {
            int len = strlen(path);
            int len_base = (is_save ? (strlen(bss.save_base) + 8) : strlen(bss.mount_base));
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, is_save);
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);
            return real_FSChangeDirAsync(pClient, pCmd, new_path, error, asyncParams);
        }
    }
    return real_FSChangeDirAsync(pClient, pCmd, path, error, asyncParams);
}
Exemplo n.º 3
0
DECL(int, FSOpenDir, void *pClient, void* pCmd, char *path, int *handle, int error) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], path, BYTE_OPEN_DIR);

        // change path if it is a game folder
        int is_save = 0;
        if (is_gamefile(path) || (is_save = is_savefile(path))) {
            int len = strlen(path);
            int len_base = (is_save ? (strlen(bss.save_base) + 8) : strlen(bss.mount_base));
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, is_save);
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);
            return real_FSOpenDir(pClient, pCmd, new_path, handle, error);
        }
    }
    return real_FSOpenDir(pClient, pCmd, path, handle, error);
}
Exemplo n.º 4
0
DECL(FSStatus, FSChangeDir, FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSRetFlag error) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], path, BYTE_CHANGE_DIR);

        // change path if it is a game folder
        int is_save = 0;
        if (is_gamefile(path) || (is_save = is_savefile(path))) {
            int len = strlen(path);
            int len_base = (is_save ? (strlen(bss.save_base) + 8) : strlen(bss.mount_base));
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, is_save);
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);
            return real_FSChangeDir(pClient, pCmd, new_path, error);
        }
    }
    return real_FSChangeDir(pClient, pCmd, path, error);
}
Exemplo n.º 5
0
DECL(int, FSOpenFileAsync, void *pClient, void *pCmd, const char *path, const char *mode, int *handle, int error, const FSAsyncParams *asyncParams) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], path, BYTE_OPEN_FILE_ASYNC);

        // change path if it is a game file
        int is_save = 0;
        if (is_gamefile(path) || (is_save = is_savefile(path))) {
            int len = strlen(path);
            int len_base = (is_save ? (strlen(bss.save_base) + 8) : strlen(bss.mount_base));
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, is_save);
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);
            return real_FSOpenFileAsync(pClient, pCmd, new_path, mode, handle, error, asyncParams);
        }
    }
    return real_FSOpenFileAsync(pClient, pCmd, path, mode, handle, error, asyncParams);
}
Exemplo n.º 6
0
// only for saves on sdcard
DECL(int, FSRemoveAsync, void *pClient, void *pCmd, char *path, int error, FSAsyncParams *asyncParams) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], path, BYTE_REMOVE);

        // change path if it is a save folder
        if (is_savefile(path)) {
            int len = strlen(path);
            int len_base = (strlen(bss.save_base) + 8);
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, 1);

            // log new path
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);

            return real_FSRemoveAsync(pClient, pCmd, new_path, error, asyncParams);
        }
    }
    return real_FSRemoveAsync(pClient, pCmd, path, error, asyncParams);
}
Exemplo n.º 7
0
/* *****************************************************************************
 * Replacement functions
 * ****************************************************************************/
DECL(int, FSGetStat, void *pClient, void *pCmd, char *path, void *stats, int error) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], path, BYTE_STAT);

        // change path if it is a game file
        int is_save = 0;
        if (is_gamefile(path) || (is_save = is_savefile(path))) {
            int len = strlen(path);
            int len_base = (is_save ? (strlen(bss.save_base) + 8) : strlen(bss.mount_base));
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, is_save);
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);

            // return function with new_path if path exists
            return real_FSGetStat(pClient, pCmd, new_path, stats, error);
        }
    }
    return real_FSGetStat(pClient, pCmd, path, stats, error);
}
Exemplo n.º 8
0
// only for saves on sdcard
DECL(FSStatus, FSMakeDir, FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSRetFlag error) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        log_string(bss.socket_fs[client], path, BYTE_MAKE_DIR);

        // change path if it is a save folder
        if (is_savefile(path)) {
            int len = strlen(path);
            int len_base = (strlen(bss.save_base) + 8);
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, 1);

            // log new path
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);

            return real_FSMakeDir(pClient, pCmd, new_path, error);
        }
    }
    return real_FSMakeDir(pClient, pCmd, path, error);
}
Exemplo n.º 9
0
DECL(int, FSRollbackQuotaAsync, void *pClient, void *pCmd, char *path, int error, FSAsyncParams *asyncParams) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        char buffer[200];
        __os_snprintf(buffer, sizeof(buffer), "FSRollbackQuotaAsync: %s", path);
        log_string(bss.global_sock, buffer, BYTE_LOG_STR);

        // change path if it is a save folder
        if (is_savefile(path)) {
            int len = strlen(path);
            int len_base = (strlen(bss.save_base) + 8);
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, 1);

            // log new path
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);

            return real_FSRollbackQuotaAsync(pClient, pCmd, new_path, error, asyncParams);
        }
    }
    return real_FSRollbackQuotaAsync(pClient, pCmd, path, error, asyncParams);
}
Exemplo n.º 10
0
DECL(int, FSGetFreeSpaceSize, void *pClient, void *pCmd, char *path, uint64_t *returnedFreeSize, int error) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        //log_string(bss.socket_fs[client], path, BYTE_REMOVE);
        char buffer[200];
        __os_snprintf(buffer, sizeof(buffer), "FSGetFreeSpaceSize: %s", path);
        log_string(bss.global_sock, buffer, BYTE_LOG_STR);

        // change path if it is a save folder
        if (is_savefile(path)) {
            int len = strlen(path);
            int len_base = (strlen(bss.save_base) + 8);
            char new_path[len + len_base + 1];
            compute_new_path(new_path, path, len, 1);

            // log new path
            log_string(bss.socket_fs[client], new_path, BYTE_LOG_STR);

            return real_FSGetFreeSpaceSize(pClient, pCmd, new_path, returnedFreeSize, error);
        }
    }
    return real_FSGetFreeSpaceSize(pClient, pCmd, path, returnedFreeSize, error);
}