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


C++ CreateDirectory函数代码示例

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


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

示例1: MessageBox

void CDBManagePageFake::OnBnClickedButtonAddtolibFake()
{
	// TODO: 在此添加控件通知处理程序代码
	if(m_ary_SpecFileName.IsEmpty())
	{
		MessageBox(L"没有要入库的光谱数据,请添加光谱数据",L"光谱入库",MB_ICONERROR);
		return ;
	}
	if(m_ary_PicturesPath.IsEmpty())
	{
		MessageBox(L"缺少必要的图片,入库失败",L"光谱入库",MB_ICONERROR);
		return ;
	}

	CCompleteSpecAddToFakeLibInfoDlg CompleteSpecAddToFakeLibInfoDlg;
	CompleteSpecAddToFakeLibInfoDlg.m_WineName=m_WineName;
	CompleteSpecAddToFakeLibInfoDlg.m_Comfrom=m_Comfrom;
	CompleteSpecAddToFakeLibInfoDlg.m_SpecIDTitle=m_SpecIDTitle;
	CompleteSpecAddToFakeLibInfoDlg.m_Manager=m_Manager;
	

	if(IDOK == CompleteSpecAddToFakeLibInfoDlg.DoModal())
	{
		if(NULL!=m_pAddToLibDlg)
		{
			m_pAddToLibDlg->DestroyWindow();
			m_pAddToLibDlg=NULL;
		}
		m_Comfrom=CompleteSpecAddToFakeLibInfoDlg.m_Comfrom;
		m_SpecIDTitle=CompleteSpecAddToFakeLibInfoDlg.m_SpecIDTitle;
		m_Manager=CompleteSpecAddToFakeLibInfoDlg.m_Manager;
		m_WineName = CompleteSpecAddToFakeLibInfoDlg.m_WineName;

		//保存图片
		CWinePictures WinePictures;
		CTime tm=CTime::GetCurrentTime();
		CString Currenttime;
		Currenttime=tm.Format("%Y-%m-%d");
		if(!WinePictures.Open())
		{
			MessageBox(L"打开图片库失败!",L"导入图片",MB_ICONERROR);
			return;
		}

		CString m_strFolderPath=g_CurrentDir;
		m_strFolderPath+=L"\\Lib\\Pictures\\";
		m_strFolderPath+=m_SpecIDTitle;

		CreateDirectory(m_strFolderPath, NULL );
		for(int i=0;i<m_ary_PicturesPath.GetCount();i++)
		{
			//生成保存图片的文件夹
			CString newpicpath;
			newpicpath.Format(L"\\Lib\\Pictures\\%s\\%s",m_SpecIDTitle,m_ary_PicturesName[i]);
			CopyFile(m_ary_PicturesPath[i],g_CurrentDir+newpicpath,0);
			WinePictures.AddNew();
			WinePictures.m_WineName=m_WineName;
			WinePictures.m_ImportDate=Currenttime;
			WinePictures.m_Manager=m_Manager;
			WinePictures.m_PicturesDir=newpicpath;
			WinePictures.m_SpecIDTitle = m_SpecIDTitle;
			WinePictures.Update();

		}
		//开始导入光谱
		m_pAddToLibDlg=new CAddToLibDlg(m_ary_SpecFilePath.GetCount(),1);
		m_pAddToLibDlg->Create(IDD_DIALOG_ADDTOLIBPROGRESS,this);
		m_pAddToLibDlg->ShowWindow(SW_SHOW);
		pThreadAddSpecToLib=AfxBeginThread(ThreadAddSpecToFakeLib,this);
	}
}
开发者ID:wth515812076,项目名称:WineAnaSys,代码行数:71,代码来源:DBManagePageFake.cpp

示例2: UpdateData

void CTabSample::OnBnClickedButtotStartsample()
{
	// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
	// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
	BOOL bSelect = FALSE;
	CButton* pButton = NULL;

	UpdateData(TRUE);
	for (int i=0; i<InstrumentNum; i++)
	{
		ProcessMessages();
		pButton = (CButton*)GetDlgItem(m_iCheckIDInstrumentFDU[i]);
		m_iSelectObject[i] = pButton->GetCheck();
		m_Sec.Lock();
		m_oThreadManage.m_oADCDataRecThread.m_iSelectObject[i] = m_iSelectObject[i];
		m_Sec.Unlock();
		pButton = NULL;
		pButton = (CButton*)GetDlgItem(m_iCheckIDNoiseFDU[i]);
		m_iSelectObjectNoise[i] = pButton->GetCheck();
		m_Sec.Lock();
		m_oThreadManage.m_oADCDataRecThread.m_iSelectObjectNoise[i] = m_iSelectObjectNoise[i];
		m_Sec.Unlock();
		pButton = NULL;
	}

	for (int i=0; i<InstrumentNum; i++)
	{
		ProcessMessages();
		if (m_iSelectObject[i] == 1)
		{	
			bSelect = TRUE;	
			break;
		}
	}

	// 至少有一个仪器被选中
	if (bSelect == TRUE)
	{
		CString str = _T("");
		CString strTemp = _T("");
		SYSTEMTIME  sysTime;
		for (int i=0; i<InstrumentNum; i++)
		{
			m_dlgADCGraphShow[i].m_bStopSample = FALSE;
		}

		m_Sec.Lock();
		m_oThreadManage.m_oADCDataRecThread.OnReset();
		m_Sec.Unlock();

		m_oThreadManage.m_oSysTimeSocket.m_uiSysTimeCount = 0;
		// 创建本次ADC数据采集数据存储文件夹

		GetLocalTime(&sysTime);
		strTemp = m_csSaveFilePath;
		strTemp += _T("\\ADC数据备份");
		str.Format(_T("_%04d_%02d_%02d_%02d_%02d_%02d_%03d"), sysTime.wYear,sysTime.wMonth,sysTime.wDay,
			sysTime.wHour,sysTime.wMinute,sysTime.wSecond,sysTime.wMilliseconds);
		strTemp += str;
		// 按日期创建保存ADC采样数据的文件夹
		CreateDirectory(strTemp,NULL);
		GetDlgItem(IDC_EDIT_ADCSAVEFRAMENB)->GetWindowText(str);
		m_uiADCFileLength = atoi(str);
		m_oThreadManage.m_oADCDataSaveToFile.m_csSaveFilePath = strTemp;
		m_oThreadManage.m_oADCDataSaveToFile.m_uiADCFileLength = m_uiADCFileLength * ReceiveDataSize;
		for (int i=0; i<InstrumentNum; i++)
		{
			m_dlgADCGraphShow[i].m_csSaveFilePath = strTemp;
			m_dlgADCGraphShow[i].m_uiADCFileLength = m_uiADCFileLength * ReceiveDataSize;
		}

		// 先做零漂矫正
		m_oThreadManage.m_oADCSetSocket.OnADCZeroDrift();

		// 发送开始采样操作命令帧
		OnSendCmdFrame(m_iSelectObject);
		GetDlgItem(IDC_BUTTOT_STARTSAMPLE)->EnableWindow(FALSE);
		GetDlgItem(IDC_BUTTON_STOPSAMPLE)->EnableWindow(TRUE);
	}
}
开发者ID:liquanhai,项目名称:cxm-hitech-matrix428,代码行数:80,代码来源:TabSample.cpp

示例3: create_directory

int create_directory(char *name)
{
    return CreateDirectory(name, NULL) != 0;
}
开发者ID:moka,项目名称:literacies,代码行数:4,代码来源:WINSFTP.C

示例4: CreateDirectory

	BOOL FileSystemLayerImpl::createDirectory(const WindEngine::String& path)
	{
		return CreateDirectory(path.c_str(), NULL) != 0 || GetLastError() == ERROR_ALREADY_EXISTS;
	}
开发者ID:523793658,项目名称:directX,代码行数:4,代码来源:FileSystemLayerImpl_WIN32.cpp

示例5: swellFileSelectProc


//.........这里部分代码省略.........
    break;
    case WM_COMMAND:
      switch (LOWORD(wParam))
      {
        case IDCANCEL: EndDialog(hwnd,0); return 0;
        case IDOK: 
          {
            char buf[1024],msg[2048];
            GetDlgItemText(hwnd,0x100,buf,sizeof(buf));
            BrowseFile_State *parms = (BrowseFile_State *)GetWindowLongPtr(hwnd,GWLP_USERDATA);
            switch (parms->mode)
            {
              case BrowseFile_State::SAVE:
                 if (!buf[0]) 
                 {
                   MessageBox(hwnd,"No file specified","Error",MB_OK);
                   return 0;
                 }
                 else  
                 {
                   struct stat st={0,};
                   DIR *dir = opendir(buf);
                   if (dir)
                   {
                     closedir(dir);
                     snprintf(msg,sizeof(msg),"Path is a directory:\r\n\r\n%s",buf);
                     MessageBox(hwnd,msg,"Invalid file",MB_OK);
                     return 0;
                   }
                   if (!stat(buf,&st))
                   {
                     snprintf(msg,sizeof(msg),"File exists:\r\n\r\n%s\r\n\r\nOverwrite?",buf);
                     if (MessageBox(hwnd,msg,"Overwrite file?",MB_OKCANCEL)==IDCANCEL) return 0;
                   }
                 }
              break;
              case BrowseFile_State::OPENDIR:
                 if (!buf[0]) 
                 { 
                   MessageBox(hwnd,"No directory specified","Error",MB_OK);
                   return 0;
                 } 
                 else
                 {
                   DIR *dir = opendir(buf);
                   if (!dir) 
                   {
                     snprintf(msg,sizeof(msg),"Error opening directory:\r\n\r\n%s\r\n\r\nCreate?",buf);
                     if (MessageBox(hwnd,msg,"Create directory?",MB_OKCANCEL)==IDCANCEL) return 0;
                     CreateDirectory(buf,NULL);
                     dir=opendir(buf);
                     if (!dir) { MessageBox(hwnd,"Error creating directory","Error",MB_OK); return 0; }
                   }
                   if (dir) closedir(dir);
                 }
              break;
              default:
                 if (!buf[0]) 
                 {
                   MessageBox(hwnd,"No file specified","Error",MB_OK);
                   return 0;
                 }
                 else  
                 {
                   struct stat st={0,};
                   DIR *dir = opendir(buf);
                   if (dir)
                   {
                     closedir(dir);
                     snprintf(msg,sizeof(msg),"Path is a directory:\r\n\r\n%s",buf);
                     MessageBox(hwnd,msg,"Invalid file",MB_OK);
                     return 0;
                   }
                   if (stat(buf,&st))
                   {
                     snprintf(msg,sizeof(msg),"File does not exist:\r\n\r\n%s",buf);
                     MessageBox(hwnd,msg,"File not found",MB_OK);
                     return 0;
                   }
                 }
              break;
            }
            if (parms->fnout) 
            {
              lstrcpyn_safe(parms->fnout,buf,parms->fnout_sz);
            }
            else
            {
              size_t l = strlen(buf);
              parms->fnout = (char*)calloc(l+2,1);
              memcpy(parms->fnout,buf,l);
            }
          }
          EndDialog(hwnd,1);
        return 0;
      }
    break;
  }
  return 0;
}
开发者ID:AdrianGin,项目名称:Pathogen,代码行数:101,代码来源:swell-miscdlg-generic.cpp

示例6: CheckFolder

int CheckFolder(char *folderName, int bCreate)
{
#ifdef _WIN32
	//检查文件夹是否存在
	WIN32_FIND_DATA wfd;
	HANDLE m_hFile = NULL;
	
	if (NULL == folderName)		return -1;
	
	m_hFile = FindFirstFile(folderName, &wfd);
	if (INVALID_HANDLE_VALUE == m_hFile)	//不存在
	{
		if (bCreate==0x01)
		{
			if (! CreateDirectory(folderName, NULL))	//创建文件夹失败
			{
				//TRACE(szLog, "创建文件夹失败: %s\n", folderName);
				return -1;
			}
			return 0;
		}
		else
		{
			return -1;
		}
	}
	else
	{
		return 0;
	}
#else

	DIR *dir = opendir(folderName);
	if (NULL != dir)
	{
		closedir(dir);
		_TRACE("Path already exist.\n");
		return 0;
	}
	else
	{
		if (bCreate==0x01)
		{
			int err = mkdir(folderName, 0755);
			if (err == 0)
			{
				_TRACE("Path not exist. create success.\n");
			}
			else
			{
				_TRACE("Path not exist. create fail.%d\n", err);
				return -1;
			}
			return 0;
		}
		else
		{
			return -1;
		}
	}

	return 0;
#endif
	return -1;
}
开发者ID:yunkaipx,项目名称:EasyDarwin,代码行数:65,代码来源:EasyRelayModule.cpp

示例7: defined

/**
 * Makes sure the path of the filename exists. If it doesn't, create the path.
 */
void Filename::verifyAndCreatePath(void) const
{
#if defined(WIN32)
	if (WindowsUnicode)
	{
		char *buffer = NULL;
		DWORD buflen;
		// get our current path
		buflen = GetFullPathName(".", 0, buffer, NULL);
		buffer = new char[buflen + 1];
		buflen = GetFullPathName(".", buflen + 1, buffer, NULL);
		Unicode::String srcPath = Unicode::narrowToWide(buffer);
		delete[] buffer;
		// get the destination path
		std::string correctPath(getDrive() + getPath());
		buflen = GetFullPathName(correctPath.c_str(), 0, buffer, NULL);
		buffer = new char[buflen + 1];
		buflen = GetFullPathName(correctPath.c_str(), buflen + 1, buffer, NULL);
		Unicode::String destPath = Unicode::narrowToWide(buffer);
		delete[] buffer;

		std::vector<Unicode::String> splitDestPath;
		splitPath(destPath, splitDestPath,
			static_cast<Unicode::unicode_char_t>(WIN32_PATH_SEPARATOR));

		Unicode::String prefix = L"\\\\?\\";
		destPath = prefix + splitDestPath[0];
		
		for (size_t i = 1; i < splitDestPath.size(); ++i)
		{
			destPath += WIN32_PATH_SEPARATOR;
			destPath += splitDestPath[i];
			if (SetCurrentDirectoryW((LPCWSTR)destPath.c_str()) == 0)
			{
				if (CreateDirectoryW((LPCWSTR)destPath.c_str(), NULL) == 0)
					return;
				if (SetCurrentDirectoryW((LPCWSTR)destPath.c_str()) == 0)
					return;
			}
		}

		// set the directory back to the working directory
		SetCurrentDirectoryW(srcPath.c_str());
	}
	else
	{
		char *buffer = NULL;
		DWORD buflen;
		// get our current path
		buflen = GetFullPathName(".", 0, buffer, NULL);
		buffer = new char[buflen + 1];
		buflen = GetFullPathName(".", buflen + 1, buffer, NULL);
		std::string srcPath = buffer;
		delete[] buffer;
		// get the destination path
		std::string correctPath(getDrive() + getPath());
		buflen = GetFullPathName(correctPath.c_str(), 0, buffer, NULL);
		buffer = new char[buflen + 1];
		buflen = GetFullPathName(correctPath.c_str(), buflen + 1, buffer, NULL);
		std::string destPath = buffer;
		delete[] buffer;

		// change to the destination path
		if (destPath.size() >= MAX_PATH)
			return;
		
		std::vector<std::string> splitDestPath;
		splitPath(destPath, splitDestPath, WIN32_PATH_SEPARATOR);

		destPath = splitDestPath[0];
		
		for (size_t i = 1; i < splitDestPath.size(); ++i)
		{
			destPath += WIN32_PATH_SEPARATOR;
			destPath += splitDestPath[i];
			if (SetCurrentDirectory(destPath.c_str()) == 0)
			{
				if (CreateDirectory(destPath.c_str(), NULL) == 0)
					return;
				if (SetCurrentDirectory(destPath.c_str()) == 0)
					return;
			}
		}

		// set the directory back to the working directory
		SetCurrentDirectory(srcPath.c_str());
	}
#elif defined(linux)
	// @todo: implement for linux
#endif
}	// Filename::verifyAndCreatePath
开发者ID:Mesagoppinmypants,项目名称:NGELinux,代码行数:94,代码来源:Filename.cpp

示例8: InitInstance

	virtual BOOL InitInstance()
	{
		try{
			SetRegistryKey(G_softwarename());

			//boost process priority
			SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);

			AfxInitRichEdit();
	//		AfxEnableControlContainer();
	//		AfxOleInit();

			{//create documents folder
				QString dir;
				GetDocumentsDir(dir);dir+=_qstr("\\");dir+=G_softwarename();
				CreateDirectory(dir,NULL);
			}


			CWinApp::InitInstance();

			//for 3D Connexion
			if (!AfxOleInit())
			{
				AfxMessageBox(L"OLE Init failed");
				return FALSE;
			}
			AfxEnableControlContainer();


			StrChar locstartupdir[600];
			GetCurrentDirectory(599,locstartupdir);
			startupdir=locstartupdir;
			datadir=startupdir+_qstr("/Data");
			{
				QString storeddatadir;
				QParamRead(PARAMLOCATION_REGISTRY,_qstr("DataDirectory"),storeddatadir);
				if (qstrlen(storeddatadir)>0)
					datadir=storeddatadir;
			}

			initlog();
			addlog(TFormatString(_text("Data directory: ^1"),datadir));

			scriptsdir=datadir;scriptsdir+=_qstr("\\Scripts");
			texturesdir=datadir;texturesdir+=_qstr("\\textures");

			addlog(_text("Fetching MAC address"));
			GetMACaddress(MACaddr);
			addlog(MACaddr);

			G_3DCosmos().LoadSettings();
			G_3DCosmos().init();


			loadstockcyclorbits();

			G_QXSys().startup();

			addlog(_text("Loading languages"),+1);
			QTranslate::Get().loadlanguages();
			addlog(_text("Loaded languages"),-1);

			addlog(_text("Creating source code window"),+1);
			mainwin= new Tmainwin();
			mainwin->createwindow(NULL,QString("Source code window"));
			addlog(_text("Source code window created"),-1);
			addlog(_text(""));
			addlog(_text(""));
			mainwin->ShowWindow(m_nCmdShow);
			m_pMainWnd=mainwin;

		}
		catch(QError &err)
		{
			reporterror(err.G_content());
		}

		return TRUE;
	}
开发者ID:pvaut,项目名称:Z-Flux,代码行数:80,代码来源:main.cpp

示例9: log_file_rotate

void log_file_rotate(LPLOGFILE logfile)
{
    struct tm	curr_tm;
    time_t	time_s;
    char	dir[128];
    char	system_cmd[128];

    time_s = time(0);
    curr_tm = *localtime(&time_s);

    if (curr_tm.tm_mday != logfile->last_day)
    {
	struct tm new_tm;
	new_tm = *tm_calc(&curr_tm, -3);

#ifndef _WIN32
	sprintf(system_cmd, "rm -rf %s/%04d%02d%02d", log_dir, new_tm.tm_year + 1900, new_tm.tm_mon + 1, new_tm.tm_mday);
#else
	sprintf(system_cmd, "del %s\\%04d%02d%02d", log_dir, new_tm.tm_year + 1900, new_tm.tm_mon + 1, new_tm.tm_mday);
#endif
	system(system_cmd);

	sys_log(0, "SYSTEM_CMD: %s", system_cmd);

	logfile->last_day = curr_tm.tm_mday;
    }

    if (curr_tm.tm_hour != logfile->last_hour)
    {
		struct stat	stat_buf;
		snprintf(dir, 128, "%s/%04d%02d%02d", log_dir, curr_tm.tm_year + 1900, curr_tm.tm_mon + 1, curr_tm.tm_mday);

		if (stat(dir, &stat_buf) != 0 || S_ISDIR(stat_buf.st_mode))
		{
#ifdef _WIN32
			CreateDirectory(dir, NULL);
#else
			mkdir(dir, S_IRWXU);
#endif
		}

		sys_log(0, "SYSTEM: LOG ROTATE (%04d-%02d-%02d %d)", 
				curr_tm.tm_year + 1900, curr_tm.tm_mon + 1, curr_tm.tm_mday, logfile->last_hour);

		// ·О±Ч ЖДАПА» ґЭ°н
		fclose(logfile->fp);

		// їЕ±дґЩ.
#ifndef _WIN32
		snprintf(system_cmd, 128, "mv %s %s/%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour);
#else
		snprintf(system_cmd, 128, "move %s %s\\%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour);
#endif
		system(system_cmd);

		// ё¶Бцё· АъАеЅГ°Ј АъАе
		logfile->last_hour = curr_tm.tm_hour;

		// ·О±Ч ЖДАПА» ґЩЅГ ї¬ґЩ.	
		logfile->fp = fopen(logfile->filename, "a+");
	}
}
开发者ID:Rarder44,项目名称:Server,代码行数:62,代码来源:log.cpp

示例10: LockCriticalSection

void CAtmoDynData::ReloadZoneDefinitionBitmaps()
{
  int i;
  // suchlogik fuer die Farbverlaufs Bitmaps ...
  // <WorkDir>\hardware\numchannels\zone..0..n.bmp
  // <WorkDir>\hardware\zone..0..n.bmp
  // <WorkDir>\zone..0..n.bmp
  // Automatik Berechnung...
  LockCriticalSection();
  if(!m_pAtmoConnection || !m_pAtmoConfig) {
      UnLockCriticalSection();
      return;
  }

  m_pAtmoConfig->UpdateZoneDefinitionCount();

  CalculateDefaultZones();


  char psz_filename[MAX_PATH];
  CAtmoZoneDefinition *zoneDef;

  sprintf(psz_filename,"%s%s",
                        m_WorkDir,
                        m_pAtmoConnection->getDevicePath()
                );
  CreateDirectory( psz_filename, NULL );

  sprintf(psz_filename,"%s%s\\%dx%dx%d",
                        m_WorkDir,
                        m_pAtmoConnection->getDevicePath(),
                        m_pAtmoConfig->getZonesTopCount(),
                        m_pAtmoConfig->getZonesLRCount(),
                        m_pAtmoConfig->getZonesBottomCount()

               );
  CreateDirectory(psz_filename, NULL );

  // try to load device depended zone definition bitmaps
  for(int zone=0; zone < m_pAtmoConfig->getZoneCount(); zone++)  {
      zoneDef = m_pAtmoConfig->getZoneDefinition(zone);
      if(!zoneDef) continue;

      sprintf(psz_filename,"%s%s\\%dx%dx%d\\zone_%d.bmp",
                        m_WorkDir,
                        m_pAtmoConnection->getDevicePath(),
                        m_pAtmoConfig->getZonesTopCount(),
                        m_pAtmoConfig->getZonesLRCount(),
                        m_pAtmoConfig->getZonesBottomCount(),
                        zone
                );
      i = zoneDef->LoadGradientFromBitmap( psz_filename );
      if(i == ATMO_LOAD_GRADIENT_OK) continue;
      if((i == ATMO_LOAD_GRADIENT_FAILED_SIZE) || (i == ATMO_LOAD_GRADIENT_FAILED_HEADER))
         MessageBox(0,psz_filename,"Failed to load, Check Format, Check Size.",MB_ICONERROR);

      sprintf(psz_filename,"%s%s\\zone_%d.bmp",
                        m_WorkDir,
                        m_pAtmoConnection->getDevicePath(),
                        zone
                );
      i = zoneDef->LoadGradientFromBitmap( psz_filename );
      if(i == ATMO_LOAD_GRADIENT_OK) continue;
      if((i == ATMO_LOAD_GRADIENT_FAILED_SIZE) || (i == ATMO_LOAD_GRADIENT_FAILED_HEADER))
         MessageBox(0,psz_filename,"Failed to load, Check Format, Check Size.",MB_ICONERROR);

      sprintf(psz_filename,"%szone_%d.bmp",
                        m_WorkDir,
                        zone
                );
      i = zoneDef->LoadGradientFromBitmap( psz_filename );
      if(i == ATMO_LOAD_GRADIENT_OK) continue;
      if((i == ATMO_LOAD_GRADIENT_FAILED_SIZE) || (i == ATMO_LOAD_GRADIENT_FAILED_HEADER))
         MessageBox(0,psz_filename,"Failed to load, Check Format, Check Size.",MB_ICONERROR);
  }

  UnLockCriticalSection();
}
开发者ID:Nevcairiel,项目名称:atmowin,代码行数:78,代码来源:AtmoDynData.cpp

示例11: CreateReparsePoint

bool CreateReparsePoint(CommandData *Cmd,const wchar *Name,FileHeader *hd)
{
  static bool PrivSet=false;
  if (!PrivSet)
  {
    SetPrivilege(SE_RESTORE_NAME);
    // Not sure if we really need it, but let's request anyway.
    SetPrivilege(SE_CREATE_SYMBOLIC_LINK_NAME);
    PrivSet=true;
  }

  const DWORD BufSize=sizeof(REPARSE_DATA_BUFFER)+2*NM+1024;
  Array<byte> Buf(BufSize);
  REPARSE_DATA_BUFFER *rdb=(REPARSE_DATA_BUFFER *)&Buf[0];

  wchar SubstName[NM];
  wcsncpyz(SubstName,hd->RedirName,ASIZE(SubstName));
  size_t SubstLength=unrar_wcslen(SubstName);

  wchar PrintName[NM],*PrintNameSrc=SubstName,*PrintNameDst=PrintName;
  bool WinPrefix=unrar_wcsncmp(PrintNameSrc,L"\\??\\",4)==0;
  if (WinPrefix)
    PrintNameSrc+=4;
  if (WinPrefix && unrar_wcsncmp(PrintNameSrc,L"UNC\\",4)==0)
  {
    *(PrintNameDst++)='\\'; // Insert second \ in beginning of share name.
    PrintNameSrc+=3;
  }
  unrar_wcscpy(PrintNameDst,PrintNameSrc);

  size_t PrintLength=unrar_wcslen(PrintName);

  bool AbsPath=WinPrefix;
  // IsFullPath is not really needed here, AbsPath check is enough.
  // We added it just for extra safety, in case some Windows version would
  // allow to create absolute targets with SYMLINK_FLAG_RELATIVE.
  if (!Cmd->AbsoluteLinks && (AbsPath || IsFullPath(hd->RedirName) ||
      !IsRelativeSymlinkSafe(hd->FileName,hd->RedirName)))
    return false;

#ifndef NOFILECREATE
  CreatePath(Name,true);

  // 'DirTarget' check is important for Unix symlinks to directories.
  // Unix symlinks do not have their own 'directory' attribute.
  if (hd->Dir || hd->DirTarget)
  {
    if (!CreateDirectory(Name,NULL))
      return false;
  }
  else
  {
    HANDLE hFile=CreateFile(Name,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
    if (hFile == INVALID_HANDLE_VALUE)
      return false;
    CloseHandle(hFile);
  }
#endif

  if (hd->RedirType==FSREDIR_JUNCTION)
  {
    rdb->ReparseTag=IO_REPARSE_TAG_MOUNT_POINT;
    rdb->ReparseDataLength=USHORT(
      sizeof(rdb->MountPointReparseBuffer.SubstituteNameOffset)+
      sizeof(rdb->MountPointReparseBuffer.SubstituteNameLength)+
      sizeof(rdb->MountPointReparseBuffer.PrintNameOffset)+
      sizeof(rdb->MountPointReparseBuffer.PrintNameLength)+
      (SubstLength+1)*sizeof(WCHAR)+(PrintLength+1)*sizeof(WCHAR));
    rdb->Reserved=0;

    rdb->MountPointReparseBuffer.SubstituteNameOffset=0;
    rdb->MountPointReparseBuffer.SubstituteNameLength=USHORT(SubstLength*sizeof(WCHAR));
    unrar_wcscpy(rdb->MountPointReparseBuffer.PathBuffer,SubstName);

    rdb->MountPointReparseBuffer.PrintNameOffset=USHORT((SubstLength+1)*sizeof(WCHAR));
    rdb->MountPointReparseBuffer.PrintNameLength=USHORT(PrintLength*sizeof(WCHAR));
    unrar_wcscpy(rdb->MountPointReparseBuffer.PathBuffer+SubstLength+1,PrintName);
  }
  else
    if (hd->RedirType==FSREDIR_WINSYMLINK || hd->RedirType==FSREDIR_UNIXSYMLINK)
    {
      rdb->ReparseTag=IO_REPARSE_TAG_SYMLINK;
      rdb->ReparseDataLength=USHORT(
        sizeof(rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset)+
        sizeof(rdb->SymbolicLinkReparseBuffer.SubstituteNameLength)+
        sizeof(rdb->SymbolicLinkReparseBuffer.PrintNameOffset)+
        sizeof(rdb->SymbolicLinkReparseBuffer.PrintNameLength)+
        sizeof(rdb->SymbolicLinkReparseBuffer.Flags)+
        (SubstLength+1)*sizeof(WCHAR)+(PrintLength+1)*sizeof(WCHAR));
      rdb->Reserved=0;

      rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset=0;
      rdb->SymbolicLinkReparseBuffer.SubstituteNameLength=USHORT(SubstLength*sizeof(WCHAR));
      unrar_wcscpy(rdb->SymbolicLinkReparseBuffer.PathBuffer,SubstName);

      rdb->SymbolicLinkReparseBuffer.PrintNameOffset=USHORT((SubstLength+1)*sizeof(WCHAR));
      rdb->SymbolicLinkReparseBuffer.PrintNameLength=USHORT(PrintLength*sizeof(WCHAR));
      unrar_wcscpy(rdb->SymbolicLinkReparseBuffer.PathBuffer+SubstLength+1,PrintName);

      rdb->SymbolicLinkReparseBuffer.Flags=AbsPath ? 0:SYMLINK_FLAG_RELATIVE;
//.........这里部分代码省略.........
开发者ID:devvit,项目名称:comicsreader,代码行数:101,代码来源:win32lnk.cpp

示例12: PrepareHookModule

int PrepareHookModule(wchar_t (&szModule)[MAX_PATH+16])
{
	int iRc = -251;
	wchar_t szNewPath[MAX_PATH+16] = {}, szAddName[32] = {}, szVer[2] = {};
	INT_PTR nLen = 0;
	bool bAlreadyExists = false;

	// Copy szModule to CSIDL_LOCAL_APPDATA and return new path
	HRESULT hr = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szNewPath);
	if ((hr != S_OK) || !*szNewPath)
	{
		iRc = -251;
		goto wrap;
	}

	szVer[0] = MVV_4a[0];
	_wsprintf(szAddName, SKIPLEN(countof(szAddName))
		L"\\" CEDEFTERMDLLFORMAT /*L"ConEmuHk%s.%02u%02u%02u%s.dll"*/,
		WIN3264TEST(L"",L"64"), MVV_1, MVV_2, MVV_3, szVer);

	nLen = lstrlen(szNewPath);
	if (szNewPath[nLen-1] != L'\\')
	{
		szNewPath[nLen++] = L'\\'; szNewPath[nLen] = 0;
	}

	if ((nLen + lstrlen(szAddName) + 8) >= countof(szNewPath))
	{
		iRc = -252;
		goto wrap;
	}

	wcscat_c(szNewPath, L"ConEmu");
	if (!DirectoryExists(szNewPath))
	{
		if (!CreateDirectory(szNewPath, NULL))
		{
			iRc = -253;
			goto wrap;
		}
	}

	wcscat_c(szNewPath, szAddName);

	if ((bAlreadyExists = FileExists(szNewPath)) && FileCompare(szNewPath, szModule))
	{
		// OK, file exists and match the required
	}
	else
	{
		if (bAlreadyExists)
		{
			_ASSERTE(FALSE && "Continue to overwrite existing ConEmuHk in AppLocal");

			// Try to delete or rename old version
			if (!DeleteFile(szNewPath))
			{
				//SYSTEMTIME st; GetLocalTime(&st);
				wchar_t szBakPath[MAX_PATH+32]; wcscpy_c(szBakPath, szNewPath);
				wchar_t* pszExt = (wchar_t*)PointToExt(szBakPath);
				msprintf(pszExt, 16, L".%u.dll", GetTickCount());
				DeleteFile(szBakPath);
				MoveFile(szNewPath, szBakPath);
			}
		}

		if (!CopyFile(szModule, szNewPath, FALSE))
		{
			iRc = -254;
			goto wrap;
		}
	}

	wcscpy_c(szModule, szNewPath);
	iRc = 0;
wrap:
	return iRc;
}
开发者ID:bradgearon,项目名称:ConEmu,代码行数:78,代码来源:InjectRemote.cpp

示例13: getHostNameFromURL

/**
 * Parse the update host and determine the updates directory
 * Then verify that the directory exists (creating if needed).
 */
void Client::initUpdatesDir()
{
    // If updatesHost is currently empty, fill it from config file
    if (mUpdateHost.empty())
        mUpdateHost = config.getStringValue("updatehost");

    // Exit on empty update host.
    if (mUpdateHost.empty())
        return;

    logger->log("Setting update host: %s", mUpdateHost.c_str());

    std::string updateHost = getHostNameFromURL(mUpdateHost);

    // Exit on a wrong update host.
    if (updateHost.length() < 2)
    {
        // Show the original updateHostname in the error message.
        errorMessage = strprintf(_("Invalid update host: %s"),
                                 mUpdateHost.c_str());
        mState = STATE_ERROR;
        return;
    }

    mUpdateHost = updateHost;
    mUpdatesDir = "updates/" + mUpdateHost;

    ResourceManager *resman = ResourceManager::getInstance();

    // Verify that the updates directory exists. Create if necessary.
    if (!resman->isDirectory("/" + mUpdatesDir))
    {
        if (!resman->mkdir("/" + mUpdatesDir))
        {
#if defined _WIN32
            std::string newDir = mLocalDataDir + "\\" + mUpdatesDir;
            std::string::size_type loc = newDir.find("/", 0);

            while (loc != std::string::npos)
            {
                newDir.replace(loc, 1, "\\");
                loc = newDir.find("/", loc);
            }

            if (!CreateDirectory(newDir.c_str(), 0) &&
                GetLastError() != ERROR_ALREADY_EXISTS)
            {
                logger->log("Error: %s can't be made, but doesn't exist!",
                            newDir.c_str());
                errorMessage =
                    strprintf(_("Error creating updates directory!\n(%s)"),
                                newDir.c_str());
                mState = STATE_ERROR;
            }
#else
            logger->log("Error: %s/%s can't be made, but doesn't exist!",
                        mLocalDataDir.c_str(), mUpdatesDir.c_str());
            errorMessage =
                strprintf(_("Error creating updates directory!\n(%s/%s)"),
                            mLocalDataDir.c_str(), mUpdatesDir.c_str());
            mState = STATE_ERROR;
#endif
        }
    }
}
开发者ID:atheros,项目名称:mana,代码行数:69,代码来源:client.cpp

示例14: _tWinMain


//.........这里部分代码省略.........
			gsVer64[0] = 0;
		}
	}
	else
	{
		wchar_t szPath[MAX_PATH+1];
		if (*gsTempFolder)
		{
			lstrcpy(szPath, gsTempFolder);
		}
		else
		{
			GetTempPath(countof(szPath) - 14, szPath);
			wchar_t* pszSubDir = szPath+lstrlen(szPath);
			lstrcpy(pszSubDir, L"ConEmu");
			pszSubDir += 6;
			lstrcpy(pszSubDir, CONEMUVERL);
		}
		
		lstrcpyn(gsMessage, L"Choose version to extract", countof(gsMessage));
		wsprintf(gsVer86, L"%s x86\nExtract installation files to\n%s", CONEMUVERL, szPath);
		wsprintf(gsVer64, L"%s x64\nExtract installation files to\n%s", CONEMUVERL, szPath);
		wsprintf(gsFull, L"%s\n\nPress `Yes` to extract x64 version\nPress `No` to extract x86 version\n\n%s", gsMessage, szPath);
	}
	
	if (nInstallVer == 0)
		nInstallVer = ChooseVersion(); // IDCANCEL/Ver86/Ver64
		
	if (nInstallVer != Ver86 && nInstallVer != Ver64)
		return 1;
	
	if (gbExtractOnly && *gsTempFolder)
	{
		CreateDirectory(gsTempFolder, NULL);
	}
	else
	{
		GetTempPath(countof(gsTempFolder) - 14, gsTempFolder);
		
		wchar_t* pszSubDir = gsTempFolder+lstrlen(gsTempFolder);
		lstrcpy(pszSubDir, L"ConEmu");
		pszSubDir += 6;
		lstrcpy(pszSubDir, CONEMUVERL);
		pszSubDir += lstrlen(pszSubDir);
		if (!CreateDirectory(gsTempFolder, NULL))
		{
			bool lbCreated = false;
			SYSTEMTIME st = {}; GetLocalTime(&st);
			for (int i = 0; i < 100; i++)
			{
				wsprintf(pszSubDir, L"_%02i%02i%02i%i", st.wHour, st.wMinute, st.wSecond, i);
				if (CreateDirectory(gsTempFolder, NULL))
				{
					lbCreated = true;
					break;
				}
			}
			if (!lbCreated)
			{
				return ReportError(10, L"Can't create temp folder\n%s", gsTempFolder);
			}
		}
	}

	wsprintf(gsMsiFile, L"%s\\ConEmu.%s.%s.msi", gsTempFolder, CONEMUVERL, (nInstallVer == Ver86) ? L"x86" : L"x64");
	wsprintf(gsCabFile, L"%s\\ConEmu.cab", gsTempFolder);
开发者ID:alexlav,项目名称:conemu,代码行数:67,代码来源:Setupper.cpp

示例15: _tcsrchr

void CCrashHandler::DumpMiniDump ( _EXCEPTION_POINTERS* pException, CExceptionInformation* pExceptionInformation )
{
    // Try to load the DLL in our directory
    HMODULE hDll = NULL;
    char szDbgHelpPath [MAX_PATH];
    if ( GetModuleFileNameA ( NULL, szDbgHelpPath, MAX_PATH ) )
    {
        char* pSlash = _tcsrchr ( szDbgHelpPath, '\\' );
        if ( pSlash )
        {
            _tcscpy ( pSlash + 1, "DBGHELP.DLL" );
            hDll = LoadLibrary ( szDbgHelpPath );
        }
    }

    // If we couldn't load the one in our dir, load any version available
    if ( !hDll )
    {
        hDll = LoadLibrary ( "DBGHELP.DLL" );
    }

    // We could load a dll?
    if ( hDll )
    {
        // Grab the MiniDumpWriteDump proc address
        MINIDUMPWRITEDUMP pDump = reinterpret_cast < MINIDUMPWRITEDUMP > ( GetProcAddress( hDll, "MiniDumpWriteDump" ) );
        if ( pDump )
        {
            // Grab the current time
            // Ask windows for the system time.
            SYSTEMTIME SystemTime;
            GetLocalTime ( &SystemTime );

            // Create the dump directory
            CreateDirectory ( ms_strDumpPath, 0 );
            CreateDirectory ( PathJoin( ms_strDumpPath, "private" ), 0 );

            SString strModuleName = pExceptionInformation->GetModuleBaseName ();
            strModuleName = strModuleName.ReplaceI ( ".dll", "" ).Replace ( ".exe", "" ).Replace ( "_", "" ).Replace ( ".", "" ).Replace ( "-", "" );
            if ( strModuleName.length () == 0 )
                strModuleName = "unknown";

            SString strFilename ( "server_%s_%s_%08x_%x_%04d%02d%02d_%02d%02d.dmp",
                                         MTA_DM_BUILDTAG_LONG,
                                         strModuleName.c_str (),
                                         pExceptionInformation->GetAddressModuleOffset (),
                                         pExceptionInformation->GetCode () & 0xffff,
                                         SystemTime.wYear,
                                         SystemTime.wMonth,
                                         SystemTime.wDay,
                                         SystemTime.wHour,
                                         SystemTime.wMinute
                                       );

            SString strFinalDumpPathFilename = PathJoin( ms_strDumpPath, "private", strFilename );

            // Create the file
            HANDLE hFile = CreateFile ( strFinalDumpPathFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
            if ( hFile != INVALID_HANDLE_VALUE )
            {
                // Create an exception information struct
                _MINIDUMP_EXCEPTION_INFORMATION ExInfo;
                ExInfo.ThreadId = GetCurrentThreadId ();
                ExInfo.ExceptionPointers = pException;
                ExInfo.ClientPointers = FALSE;

                // Write the dump
                pDump ( GetCurrentProcess(), GetCurrentProcessId(), hFile, (MINIDUMP_TYPE)( MiniDumpNormal | MiniDumpWithIndirectlyReferencedMemory ), &ExInfo, NULL, NULL );

                // Close the dumpfile
                CloseHandle ( hFile );

                FileSave( PathJoin( ms_strDumpPath, "server_pending_upload_filename" ), strFinalDumpPathFilename );
            }

            // Write a log with the generic exception information
            FILE* pFile = fopen ( PathJoin( ms_strDumpPath, "server_pending_upload.log" ), "a+" );
            if ( pFile )
            {
               // Header
                fprintf ( pFile, "%s", "** -- Unhandled exception -- **\n\n" );

                // Write the time
                time_t timeTemp;
                time ( &timeTemp );

                SString strMTAVersionFull = SString ( "%s", MTA_DM_BUILDTAG_LONG );

                SString strInfo;
                strInfo += SString ( "Version = %s\n", strMTAVersionFull.c_str () );
                strInfo += SString ( "Time = %s", ctime ( &timeTemp ) );

                strInfo += SString ( "Module = %s\n", pExceptionInformation->GetModulePathName () );

                // Write the basic exception information
                strInfo += SString ( "Code = 0x%08X\n", pExceptionInformation->GetCode () );
                strInfo += SString ( "Offset = 0x%08X\n\n", pExceptionInformation->GetAddressModuleOffset () );

                // Write the register info
                strInfo += SString ( "EAX=%08X  EBX=%08X  ECX=%08X  EDX=%08X  ESI=%08X\n" \
//.........这里部分代码省略.........
开发者ID:Anubhav652,项目名称:mtasa-blue,代码行数:101,代码来源:CCrashHandler.cpp


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