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


C++ CreateDirectoryW函数代码示例

本文整理汇总了C++中CreateDirectoryW函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateDirectoryW函数的具体用法?C++ CreateDirectoryW怎么用?C++ CreateDirectoryW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CreateDirectoryW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: win_CreateDir

static int win_CreateDir(lua_State *L)
{
	BOOL result, opt_tolerant, opt_original;
	const wchar_t* path = check_utf8_string(L, 1, NULL);
	const char* flags = "";

	if (lua_type(L,2) == LUA_TSTRING)
		flags = lua_tostring(L,2);
	else if (lua_toboolean(L,2))
		flags = "t";

	opt_tolerant = strchr(flags,'t') != NULL;
	opt_original = strchr(flags,'o') != NULL;

	if(dir_exist(path))
	{
		if (opt_tolerant) return lua_pushboolean(L,1), 1;

		return lua_pushnil(L), lua_pushliteral(L, "directory already exists"), 2;
	}

	result = opt_original ? CreateDirectoryW(path,NULL) : mkdir(path);
	if(result)
		return lua_pushboolean(L, 1), 1;

	return SysErrorReturn(L);
}
开发者ID:FarGroup,项目名称:FarManager,代码行数:27,代码来源:win.c

示例2: fix_path

Error DirAccessWindows::make_dir(String p_dir) {

	GLOBAL_LOCK_FUNCTION

	p_dir = fix_path(p_dir);
	if (p_dir.is_rel_path())
		p_dir = current_dir.plus_file(p_dir);

	p_dir = p_dir.replace("/", "\\");

	bool success;
	int err;

	p_dir = "\\\\?\\" + p_dir; //done according to
	// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855(v=vs.85).aspx

	success = CreateDirectoryW(p_dir.c_str(), NULL);
	err = GetLastError();

	if (success) {
		return OK;
	};

	if (err == ERROR_ALREADY_EXISTS || err == ERROR_ACCESS_DENIED) {
		return ERR_ALREADY_EXISTS;
	};

	return ERR_CANT_CREATE;
}
开发者ID:brakhane,项目名称:godot,代码行数:29,代码来源:dir_access_windows.cpp

示例3: __lib_CreateDirectoryW

BOOL __lib_CreateDirectoryW( LPCWSTR lpPathName,
                             LPSECURITY_ATTRIBUTES lpSecurityAttributes )
/***********************************************************************/
{
    if( WIN32_IS_NT ) {                                 /* NT */
        return( CreateDirectoryW( lpPathName, lpSecurityAttributes ) );
    } else {                                            /* Win95 or Win32s */
        char *          mbPathName;
        BOOL            osrc;
        size_t          cvt;
        size_t          len;

        /*** Allocate some memory ***/
        len = wcslen( lpPathName ) * MB_CUR_MAX + 1;
        mbPathName = lib_malloc( len );
        if( mbPathName == NULL ) {
            return( FALSE );
        }

        /*** Prepare to call the OS ***/
        cvt = wcstombs( mbPathName, lpPathName, len );
        if( cvt == (size_t)-1 ) {
            lib_free( mbPathName );
            return( FALSE );
        }

        /*** Call the OS ***/
        osrc = CreateDirectoryA( mbPathName, lpSecurityAttributes );
        lib_free( mbPathName );
        return( osrc );
    }
}
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:32,代码来源:creatdir.c

示例4: ServiceUpdate

bool ServiceUpdate(bool validService)
{
	if (validService)
	{
		ServiceInstaller si;

		if (si.run() != 0)
			return false;
	}
	else
	{
		std::wstring appPath = UTIL::OS::getCommonProgramFilesPath();

		if (!FolderExists(appPath.c_str()))
			CreateDirectoryW(appPath.c_str(), NULL);

		std::wstring newService = UTIL::OS::getCommonProgramFilesPath(L"desura_service.exe");
		std::wstring curService = UTIL::OS::getCurrentDir(L"desura_service.exe");

		char regname[255];
		Safe::snprintf(regname, 255, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\%s\\ImagePath", SERVICE_NAME);

		CopyFileW(curService.c_str(), newService.c_str(), FALSE);
		UTIL::WIN::setRegValue(regname, gcString(newService).c_str());
	}

	return true;
}
开发者ID:BlastarIndia,项目名称:Desurium,代码行数:28,代码来源:UpdateFunctions.cpp

示例5: apxLogOpen

/* Open the log file 
 * TODO: format like standard apache error.log
 * Add the EventLogger
 */
HANDLE apxLogOpen(
    APXHANDLE hPool,
    LPCWSTR szPath,
    LPCWSTR szPrefix)
{

    WCHAR sPath[MAX_PATH+1];
    WCHAR sName[MAX_PATH+1];
    SYSTEMTIME sysTime;
    apx_logfile_st *h;

    GetLocalTime(&sysTime);
    if (!szPath) {
        if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
            return INVALID_HANDLE_VALUE;
        lstrcatW(sPath, L"\\LogFiles\\");
        if (!szPrefix)
            lstrcatW(sPath, L"Apache");
        else
            lstrcatW(sPath, szPrefix);
        wsprintfW(sName, L"\\%04d%02d%02d.log",
                  sysTime.wYear,
                  sysTime.wMonth,
                  sysTime.wDay);
    }
    else {
        lstrcpyW(sPath, szPath);
        if (szPrefix)
            wsprintfW(sName, L"\\%s", szPrefix);
        else
            wsprintfW(sName, L"\\jakarta_service_%04d%02d%02d.log",
                      sysTime.wYear,
                      sysTime.wMonth,
                      sysTime.wDay);
    }
    if (!(h = (apx_logfile_st *)apxPoolCalloc(hPool, sizeof(apx_logfile_st))))
        return NULL;
    /* Set default level to info */
    h->dwLogLevel = APXLOG_LEVEL_INFO;
    CreateDirectoryW(sPath, NULL);
    
    h->sysTime = sysTime;
    lstrcpyW(h->szPath, sPath);
    lstrcatW(sPath, sName);
    if (szPrefix)
        lstrcpyW(h->szPrefix, szPrefix);

    h->hFile =  CreateFileW(sPath,
                      GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
                      NULL,
                      OPEN_ALWAYS,
                      FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
                      NULL);
    /* Set this file as system log file */
    if (!_st_sys_loghandle)
        _st_sys_loghandle = h;

    return (HANDLE)h;
}
开发者ID:huotuinc,项目名称:COMMONS_DAEMON_2_0_6,代码行数:63,代码来源:log.c

示例6: THROW_LASTERROREXCEPTION1

    bool DirectoryInfo::CreateDirectoryA(LPCSTR dirName)
    { WCHAR dirNameW[MAX_PATH];

      if( NULL!=dirName )
      { THROW_LASTERROREXCEPTION1( ::MultiByteToWideChar( CP_ACP, 0, dirName, -1,dirNameW, MAX_PATH) ); }

      return dirName!=NULL ? CreateDirectoryW(dirNameW) : false;;
    } // of DirectoryInfo::CreateDirectoryW()
开发者ID:BackupTheBerlios,项目名称:bvr20983,代码行数:8,代码来源:dirinfo.cpp

示例7: do_CreateDirectory

static int do_CreateDirectory(int argc, wchar_t **argv)
{
    if (argc != 3)
        fail("usage: CreateDirectory PathName 0");
    BOOL r = CreateDirectoryW(argv[1], 0);
    errprint(r);
    return 0;
}
开发者ID:nkzxw,项目名称:winfstest,代码行数:8,代码来源:winfstest.c

示例8: XCECreateDirectoryW

BOOL XCEAPI
XCECreateDirectoryW(const wchar_t *oldpath, LPSECURITY_ATTRIBUTES lpSec)
{
  wchar_t newpath[MAX_PATH];

  XCEFixPathW(oldpath, newpath);
  return CreateDirectoryW(newpath, lpSec);
}
开发者ID:bulk88,项目名称:celib,代码行数:8,代码来源:createdir.c

示例9: My_CreateDirectoryW

BOOL My_CreateDirectoryW()
{
	LPCWSTR lpPathName=NULL;
	LPSECURITY_ATTRIBUTES lpSecurityAttributes=NULL;
	BOOL returnVal_Real = NULL;
	BOOL returnVal_Intercepted = NULL;

	DWORD error_Real = 0;
	DWORD error_Intercepted = 0;
	disableInterception();
	returnVal_Real = CreateDirectoryW (lpPathName,lpSecurityAttributes);
	error_Real = GetLastError();
	enableInterception();
	returnVal_Intercepted = CreateDirectoryW (lpPathName,lpSecurityAttributes);
	error_Intercepted = GetLastError();
	return ((returnVal_Real == returnVal_Intercepted) && (error_Real == error_Intercepted));
}
开发者ID:IFGHou,项目名称:Holodeck,代码行数:17,代码来源:CreateDirectoryW.cpp

示例10: CreateDirectoryW

UBOOL FFileManagerWindows::InternalMakeDirectory( const TCHAR* Path, UBOOL Tree )
{
	if( Tree )
	{
		return FFileManagerGeneric::MakeDirectory( Path, Tree );
	}
	return CreateDirectoryW(Path,NULL)!=0 || GetLastError()==ERROR_ALREADY_EXISTS;
}
开发者ID:LiuKeHua,项目名称:colorful-engine,代码行数:8,代码来源:FFileManagerWindows.cpp

示例11: msi_create_directory

static BOOL msi_create_directory( MSIPACKAGE *package, const WCHAR *path )
{
    BOOL ret;
    msi_disable_fs_redirection( package );
    ret = CreateDirectoryW( path, NULL );
    msi_revert_fs_redirection( package );
    return ret;
}
开发者ID:wine-mirror,项目名称:wine,代码行数:8,代码来源:files.c

示例12: mkdir_parent

static int mkdir_parent(const wchar_t *path) {
  // Copy the path to a temporary buffer.
  wchar_t buffer[4096];
  size_t buflen = wcslen(path);
  if (buflen + 1 >= _countof(buffer)) {
    return 0;
  }
  wcscpy_s(buffer, _countof(buffer), path);

  // Seek back to find the last path separator.
  while (buflen-- > 0) {
    if (buffer[buflen] == '/' || buffer[buflen] == '\\') {
      buffer[buflen] = 0;
      break;
    }
  }
  if (buflen == (size_t)-1 || buflen == 0) {
    // There was no path separator, or this was the root directory.
    return 0;
  }

  if (CreateDirectoryW(buffer, NULL) != 0) {
    // Success!
    return 1;
  }

  // Failed.
  DWORD last_error = GetLastError();
  if (last_error == ERROR_ALREADY_EXISTS) {
    // Not really an error: the directory is already there.
    return 1;
  }

  if (last_error == ERROR_PATH_NOT_FOUND) {
    // We need to make the parent directory first.
    if (mkdir_parent(buffer)) {
      // Parent successfully created.  Try again to make the child.
      if (CreateDirectoryW(buffer, NULL) != 0) {
        // Got it!
        return 1;
      }
    }
  }
  return 0;
}
开发者ID:rdb,项目名称:panda3d,代码行数:45,代码来源:deploy-stub.c

示例13: defined

// File IO /////////////////////////////////////////////////////
Bool System::CreateDirectory( const GChar * strPathName ) const
{
#if ( defined(UNICODE) || defined (_UNICODE) )
    BOOL bRes = CreateDirectoryW( strPathName, NULL );
#else
    BOOL bRes = CreateDirectoryA( strPathName, NULL );
#endif
    return ( bRes != FALSE );
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:10,代码来源:System.cpp

示例14: efile_make_dir

posix_errno_t efile_make_dir(const efile_path_t *path) {
    ASSERT_PATH_FORMAT(path);

    if(!CreateDirectoryW((WCHAR*)path->data, NULL)) {
        return windows_to_posix_errno(GetLastError());
    }

    return 0;
}
开发者ID:HansN,项目名称:otp,代码行数:9,代码来源:win_prim_file.c

示例15: os_link_symbolic_junctions

bool os_link_symbolic_junctions(const std::wstring &target, const std::wstring &lname)
{
	bool ret=false;
	std::wstring wtarget=target;
	HANDLE hJunc=INVALID_HANDLE_VALUE;
	char *buf=NULL;

	if(wtarget.find(os_file_prefix(L""))==0)
		wtarget.erase(0, os_file_prefix(L"").size());
	if(!wtarget.empty() && wtarget[0]!='\\')
		wtarget=L"\\??\\"+wtarget;
	if(!wtarget.empty() && wtarget[target.size()-1]!='\\')
		wtarget+=L"\\";

	if(!CreateDirectoryW(lname.c_str(), NULL) )
	{
		goto cleanup;
	}

	hJunc=CreateFileW(lname.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL);
	if(hJunc==INVALID_HANDLE_VALUE)
		goto cleanup;

	size_t bsize=sizeof(REPARSE_MOUNTPOINT_DATA_BUFFER) + (wtarget.size()+1) * sizeof(wchar_t)+30;
	buf=new char[bsize];
	memset(buf, 0, bsize);

	REPARSE_MOUNTPOINT_DATA_BUFFER *rb=(REPARSE_MOUNTPOINT_DATA_BUFFER*)buf;
	rb->ReparseTag=IO_REPARSE_TAG_MOUNT_POINT;
	rb->ReparseTargetMaximumLength=(WORD)((wtarget.size()+1)*sizeof(wchar_t));
	rb->ReparseTargetLength=rb->ReparseTargetMaximumLength-1*sizeof(wchar_t);
	rb->ReparseDataLength=rb->ReparseTargetLength+12;
	memcpy(rb->ReparseTarget, wtarget.c_str(), rb->ReparseTargetMaximumLength);

	DWORD bytes_ret;
	if(!DeviceIoControl(hJunc, FSCTL_SET_REPARSE_POINT, rb, rb->ReparseDataLength+REPARSE_MOUNTPOINT_HEADER_SIZE, NULL, 0, &bytes_ret, NULL) )
	{
		goto cleanup;
	}
	ret=true;

cleanup:
	if(!ret)
	{
		#ifndef OS_FUNC_NO_SERVER
		Server->Log("Creating junction failed. Last error="+nconvert((int)GetLastError()), LL_ERROR);
		#endif
	}
	delete []buf;
	if(hJunc!=INVALID_HANDLE_VALUE)
		CloseHandle(hJunc);
	if(!ret)
	{
		RemoveDirectoryW(lname.c_str());
	}
	return ret;
}
开发者ID:Averroes,项目名称:urbackup_backend,代码行数:57,代码来源:os_functions_win.cpp


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