当前位置: 首页>>代码示例>>C++>>正文


C++ RemoveDirectoryW函数代码示例

本文整理汇总了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());
}
开发者ID:AmesianX,项目名称:wine,代码行数:33,代码来源:directory.c

示例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;
}
开发者ID:os12,项目名称:winfsp,代码行数:25,代码来源:resilient.c

示例3: removeAll

void removeAll()
{
    RemoveDirectoryW(szDirName);
    RemoveDirectoryW(szDirName_02);

    DeleteFileW(szFindName);
    DeleteFileW(szFindName_02);
    DeleteFileW(szFindName_03);
}
开发者ID:Afshintm,项目名称:coreclr,代码行数:9,代码来源:FindClose.c

示例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;
	}
开发者ID:GoddamnIndustries,项目名称:GoddamnEngine,代码行数:16,代码来源:FileUtilitiesWindows.cpp

示例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;
}
开发者ID:Averroes,项目名称:urbackup_backend,代码行数:25,代码来源:os_functions_win.cpp

示例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;
}
开发者ID:xzcvczx,项目名称:transmission,代码行数:33,代码来源:file-win32.c

示例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;
}
开发者ID:dinogun,项目名称:omr,代码行数:30,代码来源:omrfile.c

示例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;
}
开发者ID:acml,项目名称:cvsnt,代码行数:28,代码来源:FileAccess.cpp

示例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;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:12,代码来源:dir.c

示例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);
}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:33,代码来源:exec-test.c

示例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;
    }
}
开发者ID:marcomagdy,项目名称:aws-sdk-cpp,代码行数:28,代码来源:FileSystem.cpp

示例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);
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:35,代码来源:DownloadOperation.cpp

示例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);
}
开发者ID:ELMERzark,项目名称:luasys,代码行数:35,代码来源:sys_fs.c

示例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;
}
开发者ID:CarlKenner,项目名称:decaf-emu,代码行数:30,代码来源:filesystem_win_host_folder.cpp

示例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;
}
开发者ID:Elbandi,项目名称:transmission,代码行数:31,代码来源:file-win32.c


注:本文中的RemoveDirectoryW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。