本文整理汇总了C++中RemoveDirectoryW函数的典型用法代码示例。如果您正苦于以下问题:C++ RemoveDirectoryW函数的具体用法?C++ RemoveDirectoryW怎么用?C++ RemoveDirectoryW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RemoveDirectoryW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_RemoveDirectoryW
static void test_RemoveDirectoryW(void)
{
WCHAR tmpdir[MAX_PATH];
BOOL ret;
static const WCHAR tmp_dir_name[] = {'P','l','e','a','s','e',' ','R','e','m','o','v','e',' ','M','e',0};
static const WCHAR questionW[] = {'?',0};
GetTempPathW(MAX_PATH, tmpdir);
lstrcatW(tmpdir, tmp_dir_name);
ret = CreateDirectoryW(tmpdir, NULL);
if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
{
win_skip("CreateDirectoryW is not available\n");
return;
}
ok(ret == TRUE, "CreateDirectoryW should always succeed\n");
ret = RemoveDirectoryW(tmpdir);
ok(ret == TRUE, "RemoveDirectoryW should always succeed\n");
lstrcatW(tmpdir, questionW);
ret = RemoveDirectoryW(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryW with wildcard should fail with error 183, ret=%s error=%d\n",
ret ? " True" : "False", GetLastError());
tmpdir[lstrlenW(tmpdir) - 1] = '*';
ret = RemoveDirectoryW(tmpdir);
ok(ret == FALSE && GetLastError() == ERROR_INVALID_NAME,
"RemoveDirectoryW with * wildcard name should fail with error 183, ret=%s error=%d\n",
ret ? " True" : "False", GetLastError());
}
示例2: ResilientRemoveDirectoryW
BOOL WINAPI ResilientRemoveDirectoryW(
LPCWSTR lpPathName)
{
BOOL Success;
DWORD LastError;
Success = RemoveDirectoryW(lpPathName);
LastError = GetLastError();
if (Success)
WaitDeletePending(lpPathName);
else
{
for (ULONG MaxTries = DeleteMaxTries;
!Success && ERROR_SHARING_VIOLATION == GetLastError() && 0 != MaxTries;
MaxTries--)
{
Sleep(DeleteSleepTimeout);
Success = RemoveDirectoryW(lpPathName);
}
}
SetLastError(LastError);
return Success;
}
示例3: removeAll
void removeAll()
{
RemoveDirectoryW(szDirName);
RemoveDirectoryW(szDirName_02);
DeleteFileW(szFindName);
DeleteFileW(szFindName_02);
DeleteFileW(szFindName_03);
}
示例4: Sleep
/*!
* Removes the existing empty directory.
*
* @param directoryName Path to the directory.
* @returns True if directory was successfully deleted.
*/
GDAPI bool FileUtilitiesWindows::DirectoryRemove(WideString const& directoryName)
{
auto const directoryNameSystem = Paths::Platformize(directoryName);
if (RemoveDirectoryW(directoryNameSystem.CStr()) == FALSE)
{
Sleep(0);
return RemoveDirectoryW(directoryNameSystem.CStr()) == TRUE;
}
return false;
}
示例5: os_remove_nonempty_dir
bool os_remove_nonempty_dir(const std::wstring &path)
{
WIN32_FIND_DATAW wfd;
HANDLE hf=FindFirstFileW((path+L"\\*").c_str(), &wfd);
BOOL b=true;
while( b )
{
if( (std::wstring)wfd.cFileName!=L"." && (std::wstring)wfd.cFileName!=L".." )
{
if( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
os_remove_nonempty_dir(path+L"\\"+wfd.cFileName);
}
else
{
DeleteFileW((path+L"\\"+wfd.cFileName).c_str());
}
}
b=FindNextFileW(hf,&wfd);
}
FindClose(hf);
RemoveDirectoryW(path.c_str());
return true;
}
示例6: tr_sys_path_remove
bool tr_sys_path_remove(char const* path, tr_error** error)
{
TR_ASSERT(path != NULL);
bool ret = false;
wchar_t* wide_path = path_to_native_path(path);
if (wide_path != NULL)
{
DWORD const attributes = GetFileAttributesW(wide_path);
if (attributes != INVALID_FILE_ATTRIBUTES)
{
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
ret = RemoveDirectoryW(wide_path);
}
else
{
ret = DeleteFileW(wide_path);
}
}
}
if (!ret)
{
set_system_error(error, GetLastError());
}
tr_free(wide_path);
return ret;
}
示例7: omrfile_unlinkdir
int32_t
omrfile_unlinkdir(struct OMRPortLibrary *portLibrary, const char *path)
{
wchar_t unicodeBuffer[UNICODE_BUFFER_SIZE], *unicodePath;
BOOL result;
/* Convert the filename from UTF8 to Unicode */
unicodePath = file_get_unicode_path(portLibrary, path, unicodeBuffer, UNICODE_BUFFER_SIZE);
if (NULL == unicodePath) {
return -1;
}
/*PR 93036 - should be able to delete read-only dirs, so we set the file attribute back to normal*/
if (0 == SetFileAttributesW(unicodePath, FILE_ATTRIBUTE_NORMAL)) {
int32_t error = GetLastError();
portLibrary->error_set_last_error(portLibrary, error, findError(error)); /* continue */
}
result = RemoveDirectoryW(unicodePath);
if (unicodeBuffer != unicodePath) {
portLibrary->mem_free_memory(portLibrary, unicodePath);
}
if (!result) {
int32_t error = GetLastError();
portLibrary->error_set_last_error(portLibrary, error, findError(error));
return -1;
}
return 0;
}
示例8: wfile
bool CFileAccess::remove(const char *file, bool recursive /* = false */)
{
Win32Wide wfile(file);
DWORD att = GetFileAttributesW(wfile);
if(att==0xFFFFFFFF)
return false;
SetFileAttributesW(wfile,att&~FILE_ATTRIBUTE_READONLY);
if(att&FILE_ATTRIBUTE_DIRECTORY)
{
if(!recursive)
{
if(!RemoveDirectoryW(wfile))
return false;
}
else
{
cvs::wstring wpath = wfile;
if(!_remove(wpath))
return false;
}
}
else
{
if(!DeleteFileW(wfile))
return false;
}
return true;
}
示例9: MSVCRT__wrmdir
/*********************************************************************
* _wrmdir ([email protected])
*
* Unicode version of _rmdir.
*/
int CDECL MSVCRT__wrmdir(const MSVCRT_wchar_t * dir)
{
if (RemoveDirectoryW(dir))
return 0;
msvcrt_set_errno(GetLastError());
return -1;
}
示例10: exec_rename_dir_dotest
static void exec_rename_dir_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout)
{
void *memfs = memfs_start_ex(Flags, FileInfoTimeout);
WCHAR Dir1Path[MAX_PATH], Dir2Path[MAX_PATH], FilePath[MAX_PATH];
HANDLE Process;
StringCbPrintfW(Dir1Path, sizeof Dir1Path, L"%s%s\\dir1",
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
StringCbPrintfW(Dir2Path, sizeof Dir2Path, L"%s%s\\dir2",
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s\\dir1\\helper.exe",
Prefix ? L"" : L"\\\\?\\GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs));
ASSERT(CreateDirectoryW(Dir1Path, 0));
ExecHelper(FilePath, 2000, &Process);
Sleep(1000); /* give time for file handles to be closed (FlushAndPurgeOnCleanup) */
ASSERT(MoveFileExW(Dir1Path, Dir2Path, MOVEFILE_REPLACE_EXISTING));
ASSERT(MoveFileExW(Dir2Path, Dir1Path, MOVEFILE_REPLACE_EXISTING));
WaitHelper(Process, 2000);
ASSERT(DeleteFileW(FilePath));
ASSERT(RemoveDirectoryW(Dir1Path));
memfs_stop(memfs);
}
示例11: RemoveDirectoryIfExists
bool RemoveDirectoryIfExists(const char* path)
{
AWS_LOGSTREAM_INFO(FILE_SYSTEM_UTILS_LOG_TAG, "Removing directory at " << path);
if(RemoveDirectoryW(ToLongPath(Aws::Utils::StringUtils::ToWString(path)).c_str()))
{
AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The remove operation of file at " << path << " Succeeded.");
return true;
}
else
{
int errorCode = GetLastError();
if (errorCode == ERROR_DIR_NOT_EMPTY)
{
AWS_LOGSTREAM_ERROR(FILE_SYSTEM_UTILS_LOG_TAG, "The remove operation of file at " << path << " failed. with error code because it was not empty.");
}
else if(errorCode == ERROR_DIRECTORY)
{
AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The deletion of directory at " << path << " failed because it doesn't exist.");
return true;
}
AWS_LOGSTREAM_DEBUG(FILE_SYSTEM_UTILS_LOG_TAG, "The remove operation of file at " << path << " failed. with error code " << errorCode);
return false;
}
}
示例12: FindFirstFileW
void CDownloadOperation::deleteDirectoryW(LPWSTR path)
{
WIN32_FIND_DATAW fw;
std::wstring wstrPath = path ;
wstrPath += L"*.*";
HANDLE hFind= FindFirstFileW(wstrPath.c_str(), &fw);
if(hFind == INVALID_HANDLE_VALUE)
return ;
do
{
if(wcscmp(fw.cFileName,L".") == 0 || wcscmp(fw.cFileName,L"..") == 0 || wcscmp(fw.cFileName,L".svn") == 0)
continue;
if(fw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
std::wstring wstrDirectory = path;
wstrDirectory += fw.cFileName;
wstrDirectory += L"\\";
deleteDirectoryW((LPWSTR)wstrDirectory.c_str());
RemoveDirectoryW(wstrDirectory.c_str() );
}
else
{
std::wstring existingFile = path;
existingFile += fw.cFileName;
DeleteFileW(existingFile.c_str() );
}
}
while( FindNextFile(hFind,&fw) );
FindClose(hFind);
}
示例13: sys_rmdir
/*
* Arguments: path (string)
* Returns: [boolean]
*/
static int
sys_rmdir (lua_State *L)
{
const char *path = luaL_checkstring(L, 1);
int res;
#ifndef _WIN32
sys_vm_leave(L);
res = rmdir(path);
sys_vm_enter(L);
#else
{
void *os_path = utf8_to_filename(path);
if (!os_path)
return sys_seterror(L, ERROR_NOT_ENOUGH_MEMORY);
sys_vm_leave(L);
res = is_WinNT
? !RemoveDirectoryW(os_path)
: !RemoveDirectoryA(os_path);
free(os_path);
sys_vm_enter(L);
}
#endif
if (!res) {
lua_pushboolean(L, 1);
return 1;
}
return sys_seterror(L, 0);
}
示例14: findChild
bool
HostFolder::remove(const std::string &name)
{
auto hostPath = mPath.join(name);
auto winPath = platform::toWinApiString(hostPath.path());
auto child = findChild(name);
if (!child) {
// File / Directory does not exist, nothing to do
return true;
}
if (!checkPermission(Permissions::Write)) {
return false;
}
auto removed = false;
if (child->type() == NodeType::FileNode) {
removed = !!DeleteFileW(winPath.c_str());
} else if (child->type() == NodeType::FolderNode) {
removed = !!RemoveDirectoryW(winPath.c_str());
}
if (removed) {
mVirtual.deleteChild(child);
}
return removed;
}
示例15: tr_sys_path_remove
bool
tr_sys_path_remove (const char * path,
tr_error ** error)
{
bool ret = false;
wchar_t * wide_path;
assert (path != NULL);
wide_path = tr_win32_utf8_to_native (path, -1);
if (wide_path != NULL)
{
const DWORD attributes = GetFileAttributesW (wide_path);
if (attributes != INVALID_FILE_ATTRIBUTES)
{
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
ret = RemoveDirectoryW (wide_path);
else
ret = DeleteFileW (wide_path);
}
}
if (!ret)
set_system_error (error, GetLastError ());
tr_free (wide_path);
return ret;
}