示例#1
0
文件: fs.c 项目: Joonie86/loadiine
// only for saves on sdcard
DECL(int, FSRename, void *pClient, void *pCmd, char *oldPath, char *newPath, int error) {
    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_FSRename(pClient, pCmd, new_old_path, new_new_path, error);
        }
    }
    return real_FSRename(pClient, pCmd, oldPath, newPath, error);
}
示例#2
0
// only for saves on sdcard
DECL(int, FSRename, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error) {
    int client = GetCurClient(pClient);
    if (client != -1) {
        // log
        fs_log_string(bss.socket_fs[client], oldPath, BYTE_RENAME);
        fs_log_string(bss.socket_fs[client], newPath, BYTE_RENAME);

        // change path if it is a save folder
        int pathType = getPathType(oldPath);
        if (pathType == PATH_TYPE_SAVE) {
            // old path
            int len_base = getNewPathLen(pathType);
            int len_old = strlen(oldPath);
            char new_old_path[len_old + len_base + 1];
            compute_new_path(new_old_path, oldPath, len_old, pathType);

            // 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, pathType);

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

            return real_FSRename(pClient, pCmd, new_old_path, new_new_path, error);
        }
    }
    return real_FSRename(pClient, pCmd, oldPath, newPath, error);
}