/*----------------------------------------------------------------------* rtp_wfile_delete *----------------------------------------------------------------------*/ int rtp_wfile_delete (unsigned short * name) { #if (_WIN32_WINNT) >= 0x0400 #ifdef RTP_DEBUG int result; /* ----------------------------------- */ /* Clear the error state by setting */ /* to 0. */ /* ----------------------------------- */ SetLastError (0); #endif name = _rtp_unicode_name_to_winname (name); if (_wremove ((const unsigned short *)name) != 0) { #ifdef RTP_DEBUG result = GetLastError(); RTP_DEBUG_OUTPUT_STR("rtp_wfile_delete: error returned "); RTP_DEBUG_OUTPUT_INT(result); RTP_DEBUG_OUTPUT_STR(".\n"); #endif return (-1); } return (0); #endif return (-1); }
/** * g_remove: * @filename: a pathname in the GLib file name encoding (UTF-8 on Windows) * * A wrapper for the POSIX remove() function. The remove() function * deletes a name from the filesystem. * * See your C library manual for more details about how remove() works * on your system. On Unix, remove() removes also directories, as it * calls unlink() for files and rmdir() for directories. On Windows, * although remove() in the C library only works for files, this * function tries first remove() and then if that fails rmdir(), and * thus works for both files and directories. Note however, that on * Windows, it is in general not possible to remove a file that is * open to some process, or mapped into memory. * * If this function fails on Windows you can't infer too much from the * errno value. rmdir() is tried regardless of what caused remove() to * fail. Any errno value set by remove() will be overwritten by that * set by rmdir(). * * Returns: 0 if the file was successfully removed, -1 if an error * occurred * * Since: 2.6 */ int g_remove (const gchar *filename) { #ifdef G_OS_WIN32 wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); int retval; int save_errno; if (wfilename == NULL) { errno = EINVAL; return -1; } retval = _wremove (wfilename); if (retval == -1) retval = _wrmdir (wfilename); save_errno = errno; g_free (wfilename); errno = save_errno; return retval; #else return remove (filename); #endif }
////////////////////////////////////////////////////////////////////////////////////////// // Create a new file. XsensResultValue Cmt1f::create(const wchar_t* filename) { if (m_isOpen) return m_lastResult = XRV_ALREADYOPEN; #ifdef _WIN32 //! \test does this work for non-existing files? Or do we need a check and //! create? m_handle = _wfopen(filename, L"w+b"); // open for update (r/w) if (m_handle == nullptr) return m_lastResult = XRV_OUTPUTCANNOTBEOPENED; if (_wfullpath(m_filename_w, filename, CMT_MAX_FILENAME_LENGTH) == nullptr) { fclose(m_handle); _wremove(filename); return m_lastResult = XRV_INVALIDPARAM; } wcstombs(m_filename, m_filename_w, CMT_MAX_FILENAME_LENGTH); m_isOpen = true; m_readPos = 0; m_writePos = 0; m_fileSize = 0; m_reading = true; m_readOnly = false; #else MRPT_UNUSED_PARAM(filename); char tFilename[CMT_MAX_FILENAME_LENGTH * 2]; wcstombs(tFilename, m_filename_w, CMT_MAX_FILENAME_LENGTH); XsensResultValue res = create(tFilename); if (res != XRV_OK) return res; #endif m_unicode = true; return m_lastResult = XRV_OK; }
void remove_( BBString *path ){ chmod_( path,0x1b6 ); if( _bbusew ){ _wremove( bbTmpWString(path) ); }else{ remove( bbTmpCString(path) ); } }
bool BFile::delet() const { #ifdef _MSC_VER bool ret = _wremove(getFullName().c_str()) == 0; #else bool ret = remove(getFullNameUtf8().c_str()) == 0; #endif return ret; }
int SharedUtil::File::Delete(const char* szFilename) { #ifdef WIN32 return _wremove(FromUTF8(szFilename)); #else return remove(szFilename); #endif }
bool FileSystem::DeleteFile(const char* filename) { #ifdef WIN32 return _wremove(UtfPathToWidePath(filename)) == 0; #else return remove(filename) == 0; #endif }
void RemoveFile(const tWString& asFilePath) { #ifdef WIN32 _wremove(asFilePath.c_str()); #else remove(cString::To8Char(asFilePath).c_str()); #endif }
int my_wremove(const wchar_t * path) { #ifdef _WIN32 return _wremove(path); #else return remove(wideCharToUtf8(path).c_str()); #endif }
static void check_crashdump() { wchar_t * wdir = (wchar_t *)malloc(sizeof(wchar_t)*MAX_PATH); get_crashdump_path(wdir); FILE * fd = _wfopen ( wdir, L"r, ccs=UTF-8" ); if( fd ) { fclose( fd ); int answer = MessageBox( NULL, L"VLC media player just crashed." \ " Do you want to send a bug report to the developers team?", L"VLC crash reporting", MB_YESNO); if(answer == IDYES) { HINTERNET Hint = InternetOpen(L"VLC Crash Reporter", INTERNET_OPEN_TYPE_PRECONFIG, NULL,NULL,0); if(Hint) { HINTERNET ftp = InternetConnect(Hint, L"crash.videolan.org", INTERNET_DEFAULT_FTP_PORT, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0); if(ftp) { SYSTEMTIME now; GetSystemTime(&now); wchar_t remote_file[MAX_PATH]; swprintf( remote_file, L"/crashes-win32/%04d%02d%02d%02d%02d%02d", now.wYear, now.wMonth, now.wDay, now.wHour, now.wMinute, now.wSecond ); if( FtpPutFile( ftp, wdir, remote_file, FTP_TRANSFER_TYPE_BINARY, 0) ) MessageBox( NULL, L"Report sent correctly. Thanks a lot for the help.", L"Report sent", MB_OK); else MessageBox( NULL, L"There was an error while transferring to the FTP server. "\ "Thanks a lot for the help anyway.", L"Report sending failed", MB_OK); InternetCloseHandle(ftp); } else { MessageBox( NULL, L"There was an error while connecting to the FTP server. "\ "Thanks a lot for the help anyway.", L"Report sending failed", MB_OK); fprintf(stderr,"Can't connect to FTP server%d\n",GetLastError()); } InternetCloseHandle(Hint); } else { MessageBox( NULL, L"There was an error while connecting to Internet. "\ "Thanks a lot for the help anyway.", L"Reporting sending failed", MB_OK); } } _wremove(wdir); } free((void *)wdir); }
int _uremove(const char* filename){ wchar_t* wfilename; int status; if(!(wfilename = utf8_to_ucs2(filename))) return 1; status = _wremove(wfilename); free(wfilename); return status; }
static bool convert_error(const convert_params& params, const wchar_t* pError_msg) { params.m_status = false; params.m_error_message = pError_msg; _wremove(params.m_dst_filename.get_ptr()); return false; }
HRESULT CFileHelper::RemoveFile(LPCTSTR path) { #ifdef UNICODE return _wremove(path) ==0 ? S_OK : E_FAIL; #else return remove(path)==0 ? S_OK : E_FAIL; #endif }
//PRIVATE: Delete file with index 0 et rename all file i to i-1 until m_filenr-1 //After this function, the file with index m_filenr-1 is free (it doesn't exist) void CLog::renameFiles(const wchar_t *root_filename) { //We remove the file 0 std::wstring src; src=root_filename; src+=L"0.log"; #ifdef WIN32 _wremove(src.c_str()); #else remove(utilStringNarrow(src).c_str()); #endif std::wstring dest; wchar_t isrc[5]; wchar_t idest[5]; #ifdef WIN32 struct _stat results; #else struct stat results; #endif //For all file until m_filenr-1 // 1 become 0 // 2 become 1 //i+1 become i //m_filenr-1 become m_filenr-2 for(int i=0;i<m_filenr;i++) { swprintf_s(isrc,5,L"%d",i+1); swprintf_s(idest,5,L"%d",i); //if the source does not exist, we stop src=root_filename; src+=isrc; src+=L".log"; #ifdef WIN32 if (_wstat(src.c_str(), &results) != 0) break; #else if (stat(utilStringNarrow(src).c_str(), &results) != 0) break; #endif dest=root_filename; dest+=idest; dest+=L".log"; //Rename of the file #ifdef WIN32 _wrename(src.c_str(),dest.c_str()); #else rename(utilStringNarrow(src).c_str(),utilStringNarrow(dest).c_str()); #endif } }
bool UMPath::remove_file(const umstring& file_path) { std::wstring path = UMStringUtil::utf16_to_wstring(file_path); if (UMPath::exists(file_path) && !UMPath::is_folder(file_path)) { _wremove(path.c_str()); return true; } return false; }
static int os_remove (lua_State *L) { const char *filename = luaL_checkstring(L, 1); #ifdef WIN32 wchar_t wfilename[MAX_PATH+1]; MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, MAX_PATH+1); return os_pushresult(L, _wremove(wfilename), filename); #else // FIXME: non-win32 conversion to local filesystem encoding? return os_pushresult(L, remove(filename) == 0, filename); #endif }
int SAUtf8WRemove( const char *pszFilename ) { const wchar_t *pwszFileName = Utf8ToWideChar( pszFilename ); int rc = -1; if( pwszFileName != NULL ) { rc = _wremove( pwszFileName ); } free ((wchar_t*) pwszFileName); return rc; }
void CjocLog::Initialize (std::wstring &strFile, unsigned long lMaxFileSize, bool bAddLogWhenCreateFile) { bool bCreate = false; if (strFile.empty () == true){throw JOC_Error_(enjocErrors::err_bad_arguments);} FILE *pFile = NULL; pFile = _wfopen (strFile.c_str (),L"r"); if (pFile != NULL) { //Exists fclose (pFile); //Set file m_strFile = strFile; struct _stat64i32 buf; _wstat(m_strFile.c_str (),&buf); if (buf.st_size > lMaxFileSize) { std::wstring strNewFileName; strNewFileName = m_strFile + L".old"; //Delete .old if exists _wremove(strNewFileName.c_str ()); int nRc = _wrename (m_strFile.c_str (),strNewFileName.c_str ()); if (nRc != 0){throw JOC_Error_arg_(enjocErrors::err_renaming_file,m_strFile.c_str ());} bCreate = true; } } else { bCreate = true; } if (bCreate == true) { //Create pFile = _wfopen (strFile.c_str (),L"w"); if (pFile == NULL){throw JOC_Error_arg_(enjocErrors::err_creating_file_for_write,strFile.c_str ());} fclose (pFile); //Set file m_strFile = strFile; if (bAddLogWhenCreateFile == true) Append((std::wstring)L"Log file created"); } }
// ru: Удаление файла (аналог "remove") // en: Deleting of file (analogue "remove") int MP_Platform_WIN_POSIX::RemoveFile(const char* file) { #ifdef _WINDOWS return _wremove(utf8_to_wchar(file)); #else return remove(file); #endif }
/* 输 入: lpszFileName(const wchar_t*) - [in]日志文件路径 输 出: - 功 能: 删除日志文件 */ void DelFile(const wchar_t* lpszFileName) { errno_t err; int nDelRet = _wremove(lpszFileName); if (-1 == nDelRet) { _get_errno(&err); wprintf(L"Cannot delete the file. Error code is %d\n", err); } }
int u8remove(const char *fname) { wchar_t *wfname; int r = -1; wfname = u8stows(fname); if(wfname) { r = _wremove(wfname); free(wfname); } return r; }
hpatch_BOOL hpatch_removeFile(const char* fileName_utf8){ _path_noEndDirSeparator(fileName,fileName_utf8);{ #if (_IS_USED_WIN32_UTF8_WAPI) int wsize; wchar_t path_w[hpatch_kPathMaxSize]; wsize=_utf8FileName_to_w(fileName,path_w,hpatch_kPathMaxSize); if (wsize<=0) return hpatch_FALSE; return 0==_wremove(path_w); #else return 0==remove(fileName); #endif } }
int _shttpd_remove(const char *path) { char buf[FILENAME_MAX]; wchar_t wbuf[FILENAME_MAX]; _shttpd_strlcpy(buf, path, sizeof(buf)); fix_directory_separators(buf); MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, sizeof(wbuf)); return (_wremove(wbuf)); }
////////////////////////////////////////////////////////////////////////////////////////// // Close the file and delete it. XsensResultValue Cmt1f::closeAndDelete(void) { if (m_isOpen) { #ifdef _WIN32 fflush(m_handle); fclose(m_handle); #else ::fflush(m_handle); ::fclose(m_handle); #endif if (m_readOnly) m_lastResult = XRV_READONLY; else { #ifdef _WIN32 if (m_unicode) { if (_wremove(m_filename_w) != 0) m_lastResult = XRV_READONLY; else m_lastResult = XRV_OK; } else #endif { #ifdef _WIN32 if (_unlink(m_filename) != 0) #else if (unlink(m_filename) != 0) #endif m_lastResult = XRV_READONLY; else m_lastResult = XRV_OK; } } } else m_lastResult = XRV_NOFILEOPEN; m_isOpen = false; m_readPos = 0; m_writePos = 0; m_reading = true; m_isOpen = false; m_fileSize = 0; m_readOnly = false; return m_lastResult; }
// remove menupath and its parent directories // argument menupath will be destroyed void MetaLauncher::removeMenu(wchar_t *menuPath) { if (_wremove(menuPath) != 0) { vnclog.Print(0, _T("failed to remove link. (error %d)\n"), GetLastError()); return; } // remove link filename from menupath wchar_t *p; p = wcsrchr(menuPath, L'\\'); if (p == NULL) return; *p = L'\0'; removeMenuDirs(menuPath); }
//!ファイル名の変更。失敗した場合は例外を投げる。 void Io::rename( const wchar_t* oldpath, const wchar_t* newpath, bool overwrite) { //oldpathの存在チェック if(!fexist(oldpath))throw myexception(L"rename: oldpath[%s]が存在しません",oldpath); //上書きを許す場合、新しいパスに存在するファイルを削除 if(overwrite)_wremove(newpath); //rename実行 int ret=::_wrename(oldpath,newpath); if(ret!=0){ throw myexception(L"rename(%s,%s) failed.",oldpath,newpath); } }
bool checkDirWritable(const std::string& path) { //FIXME: more correct file name. #ifdef WIN32 FILE *fp = _wfopen(fromUTF8(path + L"\\98hj8u.tmp").c_str(), L"w"); #else FILE *fp = fopen((path + "/98hj8u.tmp").c_str(), "w"); #endif if (fp == NULL) return false; fclose(fp); #ifdef WIN32 _wremove(fromUTF8(path + L"\\98hj8u.tmp").c_str()); #else remove((path + "/98hj8u.tmp").c_str()); #endif return true; }
int fz_remove_utf8(const char *name) { wchar_t *wname; int n; wname = fz_wchar_from_utf8(name); if (wname == NULL) { errno = ENOMEM; return -1; } n = _wremove(wname); free(wname); return n; }
MetaLauncher::~MetaLauncher() { clear(); removeMenuDirs(m_baseMenuFolder); // close and delete menulist file if (m_fpMenuList) fclose(m_fpMenuList); if (SetCurrentDirectoryW(m_baseDataFolder)) { _wremove(menuListName); SetCurrentDirectoryW(L".."); } RemoveDirectoryW(m_baseDataFolder); delete[] m_desktopFolderName; if (m_baseMenuFolder) delete[] m_baseMenuFolder; if (m_baseDataFolder) delete[] m_baseDataFolder; }
int retro_vfs_file_remove_impl(const char *path) { char *path_local = NULL; wchar_t *path_wide = NULL; if (!path || !*path) return -1; (void)path_local; (void)path_wide; #if defined(_WIN32) && !defined(_XBOX) #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 path_local = utf8_to_local_string_alloc(path); if (path_local) { int ret = remove(path_local); free(path_local); if (ret == 0) return 0; } #else path_wide = utf8_to_utf16_string_alloc(path); if (path_wide) { int ret = _wremove(path_wide); free(path_wide); if (ret == 0) return 0; } #endif #else if (remove(path) == 0) return 0; #endif return -1; }