本文整理匯總了C++中DeleteFileW函數的典型用法代碼示例。如果您正苦於以下問題:C++ DeleteFileW函數的具體用法?C++ DeleteFileW怎麽用?C++ DeleteFileW使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DeleteFileW函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: fal_unlink
bool fal_unlink( const String &filename, int32 &fsStatus )
{
String fname = filename;
Path::uriToWin( fname );
AutoWString wBuffer( fname );
BOOL res = DeleteFileW( wBuffer.w_str() );
if( ! res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED )
{
AutoCString cBuffer( fname );
res = DeleteFile( cBuffer.c_str() );
}
if ( res == TRUE ) {
return true;
}
fsStatus = GetLastError();
return false;
}
示例2: file_copy_using_memory_map
/**
* @brief
* @param
* @see
* @remarks
* @code
* @endcode
* @return
**/
bool
file_copy_using_memory_map(
_In_ const wchar_t* src_file,
_In_ const wchar_t* dst_file
)
{
_ASSERTE(NULL != src_file);
_ASSERTE(NULL != dst_file);
if (NULL == src_file || NULL == dst_file) return false;
if (!is_file_existsW(src_file))
{
print("err ] no src file = %ws", src_file);
return false;
}
if (is_file_existsW(dst_file))
{
DeleteFileW(dst_file);
}
// map src, dst file
pmap_context src_ctx = open_map_context(src_file);
pmap_context dst_ctx = create_map_context(dst_file, src_ctx->size);
if (NULL == src_ctx || NULL == dst_ctx)
{
print("err ] open_map_context() failed.");
close_map_context(src_ctx);
close_map_context(dst_ctx);
return false;
}
// copy src to dst by mmio
for (uint32_t i = 0; i < src_ctx->size; ++i)
{
dst_ctx->view[i] = src_ctx->view[i];
}
close_map_context(src_ctx);
close_map_context(dst_ctx);
return true;
}
示例3: delete_unique
static bool delete_unique(const char *path, const bool dir)
{
bool err;
UTF16_ENCODE(path);
if (dir) {
err = !RemoveDirectoryW(path_16);
if (err) printf("Unable to remove directory");
}
else {
err = !DeleteFileW(path_16);
if (err) callLocalErrorCallBack("Unable to delete file");
}
UTF16_UN_ENCODE(path);
return err;
}
示例4: main
int main(int argc, char *argv[])
{
WCHAR src[4] = {'f', 'o', 'o', '\0'};
WCHAR dest[4] = {'b', 'a', 'r', '\0'};
WCHAR dir[5] = {'/', 't', 'm', 'p', '\0'};
HANDLE h;
unsigned int b;
PAL_Initialize(argc, (const char**)argv);
SetCurrentDirectoryW(dir);
SetCurrentDirectoryW(dir);
h = CreateFileW(src, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL);
WriteFile(h, "Testing\n", 8, &b, FALSE);
CloseHandle(h);
CopyFileW(src, dest, FALSE);
DeleteFileW(src);
PAL_Terminate();
return 0;
}
示例5: iop_rmfile
int
iop_rmfile(io_args_t *const args)
{
const char *const path = args->arg1.path;
uint64_t size;
int result;
ioeta_update(args->estim, path, path, 0, 0);
size = get_file_size(path);
#ifndef _WIN32
result = unlink(path);
if(result != 0)
{
(void)ioe_errlst_append(&args->result.errors, path, errno, strerror(errno));
}
#else
{
wchar_t *const utf16_path = utf8_to_utf16(path);
const DWORD attributes = GetFileAttributesW(utf16_path);
if(attributes & FILE_ATTRIBUTE_READONLY)
{
SetFileAttributesW(utf16_path, attributes & ~FILE_ATTRIBUTE_READONLY);
}
result = !DeleteFileW(utf16_path);
if(result)
{
/* FIXME: use real system error message here. */
(void)ioe_errlst_append(&args->result.errors, path, IO_ERR_UNKNOWN,
"Directory removal failed");
}
free(utf16_path);
}
#endif
ioeta_update(args->estim, NULL, NULL, 1, size);
return result;
}
示例6: GetFileAttributesW
void WinNode::remove_impl(const std::string& name)
{
std::wstring nativePath = m_nativePath + L"\\" + win32::multiByteToWideChar(name);
DWORD dw = GetFileAttributesW(nativePath.c_str());
if (dw == INVALID_FILE_ATTRIBUTES)
return win32::ThrowLastError("WinNode::remove_impl: '%s'", name.c_str());
if (dw & FILE_ATTRIBUTE_DIRECTORY)
{
if (!RemoveDirectoryW(nativePath.c_str()))
win32::ThrowLastError("WinNode::remove_impl: '%s'", name.c_str());
}
else
{
if (!DeleteFileW(nativePath.c_str()))
win32::ThrowLastError("WinNode::remove_impl: '%s'", name.c_str());
}
}
示例7: ucmRegisterAndRunTarget
/*
* ucmRegisterAndRunTarget
*
* Purpose:
*
* Register shim database and execute target app.
*
*/
BOOL ucmRegisterAndRunTarget(
_In_ LPWSTR lpSystemDirectory,
_In_ LPWSTR lpSdbinstPath,
_In_ LPWSTR lpShimDbPath,
_In_ LPWSTR lpTarget,
_In_ BOOL IsPatch
)
{
BOOL bResult = FALSE;
WCHAR szTempDirectory[MAX_PATH * 2];
WCHAR szCmd[MAX_PATH * 4];
if ((lpTarget == NULL) ||
(lpSystemDirectory == NULL) ||
(lpSdbinstPath == NULL) ||
(lpShimDbPath == NULL)
)
{
return bResult;
}
RtlSecureZeroMemory(szCmd, sizeof(szCmd));
if (IsPatch) {
wsprintf(szCmd, L"-p %ws", lpShimDbPath);
}
else {
_strcpy_w(szCmd, lpShimDbPath);
}
//register shim, sdbinst.exe
if (supRunProcess(lpSdbinstPath, szCmd)) {
RtlSecureZeroMemory(szTempDirectory, sizeof(szTempDirectory));
wsprintfW(szTempDirectory, lpTarget, lpSystemDirectory);
bResult = supRunProcess(szTempDirectory, NULL);
//remove database
RtlSecureZeroMemory(szCmd, sizeof(szCmd));
wsprintf(szCmd, L"/q /u %ws", lpShimDbPath);
supRunProcess(lpSdbinstPath, szCmd);
DeleteFileW(lpShimDbPath);
}
return bResult;
}
示例8: clean_up
static void clean_up(void)
{
if(tmp_file != INVALID_HANDLE_VALUE)
CloseHandle(tmp_file);
if(tmp_file_name) {
DeleteFileW(tmp_file_name);
heap_free(tmp_file_name);
tmp_file_name = NULL;
}
if(tmp_file != INVALID_HANDLE_VALUE) {
CloseHandle(tmp_file);
tmp_file = INVALID_HANDLE_VALUE;
}
if(install_dialog)
EndDialog(install_dialog, 0);
}
示例9: CoCreateInstance
HRESULT CMediaFileList::AddVideoFile(BSTR FilePath, IMediaFile **ppResult)
{
HRESULT hr = CoCreateInstance(CLSID_MediaFile, NULL,
CLSCTX_INPROC_SERVER,
IID_IMediaFile,
(void **)ppResult);
if (FAILED(hr) || *ppResult == NULL)
return E_POINTER;
(*ppResult)->AddRef();
(*ppResult)->put_FilePath(FilePath);
CComBSTR strPosterPath;
double dDuration = 0;
hr = GetFileInfo(FilePath, 0, &dDuration, 0, 0, 0, 0, 0, &strPosterPath);
if (SUCCEEDED(hr))
{
(*ppResult)->put_Duration(dDuration);
}
(*ppResult)->put_PosterFramePath(strPosterPath);
(*ppResult)->put_StartOffset(GetCurrentVideoLength());
if (dDuration == 0.0)
{
(*ppResult)->put_IsImage(VARIANT_TRUE);
(*ppResult)->put_Duration(7);
}
else
(*ppResult)->put_IsImage(VARIANT_FALSE);
// USES_CONVERSION;
DeleteFileW(strPosterPath);
m_videoList.AddTail(*ppResult);
(*ppResult)->AddRef();
return S_OK;
}
示例10: __win_fs_rename
/*
* __win_fs_rename --
* Rename a file.
*/
static int
__win_fs_rename(WT_FILE_SYSTEM *file_system,
WT_SESSION *wt_session, const char *from, const char *to, uint32_t flags)
{
DWORD windows_error;
WT_DECL_RET;
WT_DECL_ITEM(from_wide);
WT_DECL_ITEM(to_wide);
WT_SESSION_IMPL *session;
WT_UNUSED(file_system);
WT_UNUSED(flags);
session = (WT_SESSION_IMPL *)wt_session;
WT_ERR(__wt_to_utf16_string(session, from, &from_wide));
WT_ERR(__wt_to_utf16_string(session, to, &to_wide));
/*
* Check if file exists since Windows does not override the file if
* it exists.
*/
if (GetFileAttributesW(to_wide->data) != INVALID_FILE_ATTRIBUTES)
if (DeleteFileW(to_wide->data) == FALSE) {
windows_error = __wt_getlasterror();
__wt_errx(session,
"%s: file-rename: DeleteFileW: %s",
to, __wt_formatmessage(session, windows_error));
WT_ERR(__wt_map_windows_error(windows_error));
}
if (MoveFileW(from_wide->data, to_wide->data) == FALSE) {
windows_error = __wt_getlasterror();
__wt_errx(session,
"%s to %s: file-rename: MoveFileW: %s",
from, to, __wt_formatmessage(session, windows_error));
WT_ERR(__wt_map_windows_error(windows_error));
}
err: __wt_scr_free(session, &from_wide);
__wt_scr_free(session, &to_wide);
return (ret);
}
示例11: GameStatisticsMgrImpl_RemoveGameStatistics
static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_RemoveGameStatistics(
IGameStatisticsMgr* iface,
LPCWSTR GDFBinaryPath)
{
HRESULT hr;
WCHAR lpApplicationId[49];
WCHAR sStatsFile[MAX_PATH];
TRACE("(%p, %s)\n", iface, debugstr_w(GDFBinaryPath));
hr = GAMEUX_getAppIdFromGDFPath(GDFBinaryPath, lpApplicationId);
if(SUCCEEDED(hr))
hr = GAMEUX_buildStatisticsFilePath(lpApplicationId, sStatsFile);
if(SUCCEEDED(hr))
hr = (DeleteFileW(sStatsFile)==TRUE ? S_OK : HRESULT_FROM_WIN32(GetLastError()));
return hr;
}
示例12: OnClearRecentItems
VOID OnClearRecentItems()
{
WCHAR szPath[MAX_PATH], szFile[MAX_PATH];
WIN32_FIND_DATA info;
HANDLE hPath;
if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_RECENT, NULL, 0, szPath)))
{
StringCchPrintf(szFile,MAX_PATH, L"%s\\*.*", szPath);
hPath = FindFirstFileW(szFile, &info);
do
{
StringCchPrintf(szFile,MAX_PATH, L"%s\\%s", szPath, info.cFileName);
DeleteFileW(szFile);
}while(FindNextFileW(hPath, &info));
FindClose(hPath);
/* FIXME: Disable the button*/
}
}
示例13: wxRemoveFile
//---------------------------------------------------------------------------
bool File::Delete(const Ztring &File_Name)
{
#ifdef ZENLIB_USEWX
return wxRemoveFile(File_Name.c_str());
#else //ZENLIB_USEWX
#ifdef ZENLIB_STANDARD
#ifdef UNICODE
return unlink(File_Name.To_Local().c_str())==0;
#else
return unlink(File_Name.c_str())==0;
#endif //UNICODE
#elif defined WINDOWS
#ifdef UNICODE
return DeleteFileW(File_Name.c_str())!=0;
#else
return DeleteFile(File_Name.c_str())!=0;
#endif //UNICODE
#endif
#endif //ZENLIB_USEWX
}
示例14: MSTASK_ITaskScheduler_Delete
static HRESULT WINAPI MSTASK_ITaskScheduler_Delete(ITaskScheduler *iface, LPCWSTR name)
{
static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 };
static const WCHAR jobW[] = { '.','j','o','b',0 };
WCHAR task_name[MAX_PATH];
TRACE("%p, %s\n", iface, debugstr_w(name));
if (strchrW(name, '.')) return E_INVALIDARG;
GetWindowsDirectoryW(task_name, MAX_PATH);
lstrcatW(task_name, tasksW);
lstrcatW(task_name, name);
lstrcatW(task_name, jobW);
if (!DeleteFileW(task_name))
return HRESULT_FROM_WIN32(GetLastError());
return S_OK;
}
示例15: install_from_cache
static enum install_res install_from_cache(void)
{
WCHAR *cache_file_name;
enum install_res res;
cache_file_name = get_cache_file_name(FALSE);
if(!cache_file_name)
return INSTALL_NEXT;
if(!sha_check(cache_file_name)) {
WARN("could not validate checksum\n");
DeleteFileW(cache_file_name);
heap_free(cache_file_name);
return INSTALL_NEXT;
}
res = install_file(cache_file_name);
heap_free(cache_file_name);
return res;
}