int xbp_rename(const char *oldname, const char *newname) { char* o = strdup(oldname); char* n = strdup(newname); CORRECT_SEP_STR(o); CORRECT_SEP_STR(n); int res = rename(_P(o).c_str(), _P(n).c_str()); free(o); free(n); return res; }
extern "C" HANDLE WINAPI dllFindFirstFileA(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData) { char* p = strdup(lpFileName); CORRECT_SEP_STR(p); // change default \\*.* into \\* which the xbox is using char* e = strrchr(p, '.'); if (e != NULL && strlen(e) > 1 && e[1] == '*') { e[0] = '\0'; } #ifdef TARGET_WINDOWS struct _WIN32_FIND_DATAW FindFileDataW; std::wstring strwfile; g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(p), strwfile, false); HANDLE res = FindFirstFileW(strwfile.c_str(), &FindFileDataW); if (res != INVALID_HANDLE_VALUE) to_WIN32_FIND_DATA(&FindFileDataW, lpFindFileData); #else HANDLE res = FindFirstFile(CSpecialProtocol::TranslatePath(p).c_str(), lpFindFileData); #endif free(p); return res; }
int xbp_unlink(const char *filename) { char* p = strdup(filename); CORRECT_SEP_STR(p); int res = unlink(_P(p).c_str()); free(p); return res; }
char* xbp__tempnam(const char *dir, const char *prefix) { char* p = strdup(dir); CORRECT_SEP_STR(p); char* res = _tempnam(p, prefix); free(p); return strdup(res); }
int xbp_open(const char *filename, int oflag, int pmode) { char* p = strdup(filename); CORRECT_SEP_STR(p); int res = open(_P(p).c_str(), oflag, pmode); free(p); return res; }
int xbp_mkdir(const char *dirname) { char* p = strdup(dirname); CORRECT_SEP_STR(p); int res = mkdir(_P(p).c_str()); free(p); return res; }
int xbp_utime(const char *filename, struct utimbuf *times) { char* p = strdup(filename); CORRECT_SEP_STR(p); int res = utime(_P(p).c_str(), times); free(p); return res; }
int xbp_chmod(const char *filename, int pmode) { char* p = strdup(filename); CORRECT_SEP_STR(p); int res = chmod(_P(p).c_str(), pmode); free(p); return res; }
int xbp_access(const char *path, int mode) { char* p = strdup(path); CORRECT_SEP_STR(p); int res = access(_P(p).c_str(), mode); free(p); return res; }
int xbp_chdir(const char *dirname) { if (strlen(dirname) > MAX_PATH) return -1; strcpy(xbp_cw_dir, dirname); CORRECT_SEP_STR(xbp_cw_dir); return 0; }
HANDLE xbp_FindFirstFile(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData) { char* p = strdup(lpFileName); CORRECT_SEP_STR(p); // change default \\*.* into \\* which the xbox is using char* e = strrchr(p, '.'); if (e != NULL && strlen(e) > 1 && e[1] == '*') { e[0] = '\0'; } HANDLE res = FindFirstFile(_P(p).c_str(), lpFindFileData); free(p); return res; }
FILE* xbp_fopen(const char *filename, const char *mode) { //convert '/' to '\\' char cName[1024]; char* p; strcpy(cName, filename); CORRECT_SEP_STR(cName); //for each "\\..\\" remove the directory before it while(p = strstr(cName, "\\..\\")) { char* file = p + 3; *p = '\0'; *strrchr(cName, '\\') = '\0'; strcat(cName, file); } // don't use emulated files, they do not work in python yet return fopen_utf8(_P(cName).c_str(), mode); }