您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetFileAttributes函数代码示例

51自学网 2021-06-01 21:07:43
  C++
这篇教程C++ GetFileAttributes函数代码示例写得很实用,希望能帮到您。

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

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

示例1: Map_SaveFile

/* =======================================================================================================================    Map_SaveFile ======================================================================================================================= */bool Map_SaveFile(const char *filename, bool use_region, bool autosave){	entity_t	*e, *next;	idStr		temp;	int			count;	brush_t		*b;	idStr status;	int len = strlen(filename);	WIN32_FIND_DATA FileData;	if (FindFirstFile(filename, &FileData) != INVALID_HANDLE_VALUE) {		// the file exists;		if (len > 0 && GetFileAttributes(filename) & FILE_ATTRIBUTE_READONLY) {			g_pParentWnd->MessageBox("File is read only", "Read Only", MB_OK);			return false;		}	}	if (filename == NULL || len == 0 || (filename && stricmp(filename, "unnamed.map") == 0)) {		CFileDialog dlgSave(FALSE,"map",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Map Files (*.map)|*.map||",AfxGetMainWnd());		if (dlgSave.DoModal() == IDOK) {			filename = dlgSave.m_ofn.lpstrFile;			strcpy(currentmap, filename);		} else {			return false;		}	}	MEMORYSTATUSEX statex;	statex.dwLength = sizeof(statex);	GlobalMemoryStatusEx(&statex);	if (statex.dwMemoryLoad > 95) {		g_pParentWnd->MessageBox("Physical memory is over 95% utilized. Consider saving and restarting", "Memory");	}	CWaitDlg dlg;	Pointfile_Clear();	temp = filename;	temp.BackSlashesToSlashes();	if (!use_region) {		idStr backup;		backup = temp;		backup.StripFileExtension();		backup.SetFileExtension(".bak");		if (_unlink(backup) != 0 && errno != 2) {   // errno 2 means the file doesn't exist, which we don't care about			g_pParentWnd->MessageBox(va("Unable to delete %s: %s", backup.c_str(), strerror(errno)), "File Error");		}		if (rename(filename, backup) != 0) {			g_pParentWnd->MessageBox(va("Unable to rename %s to %s: %s", filename, backup.c_str(), strerror(errno)), "File Error");		}	}	common->Printf("Map_SaveFile: %s/n", filename);	idStr mapFile;	bool localFile = (strstr(filename, ":") != NULL);	if (autosave || localFile) {		mapFile = filename;	} else {		mapFile = fileSystem->OSPathToRelativePath(filename);	}	if (use_region) {		AddRegionBrushes();	}	idMapFile map;	world_entity->origin.Zero();	idMapEntity *mapentity = EntityToMapEntity(world_entity, use_region, &dlg);	dlg.SetText("Saving worldspawn...");	map.AddEntity(mapentity);	if (use_region) {		idStr buf;		sprintf(buf, "{/n/"classname/"    /"info_player_start/"/n/"origin/"/t /"%i %i %i/"/n/"angle/"/t /"%i/"/n}/n",		        (int)g_pParentWnd->GetCamera()->Camera().origin[0],		        (int)g_pParentWnd->GetCamera()->Camera().origin[1],		        (int)g_pParentWnd->GetCamera()->Camera().origin[2],		        (int)g_pParentWnd->GetCamera()->Camera().angles[YAW]);		idLexer src(LEXFL_NOSTRINGCONCAT | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES);		src.LoadMemory(buf, buf.Length(), "regionbuf");		idMapEntity *playerstart = idMapEntity::Parse(src);		map.AddEntity(playerstart);	}	count = -1;//.........这里部分代码省略.........
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:101,


示例2: sl_file_exists

intsl_file_exists(sl_vm_t* vm, char* path){    DWORD dwAttrib = GetFileAttributes(sl_realpath(vm, path));    return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));}
开发者ID:tinkertim,项目名称:slash,代码行数:6,


示例3: IsDirectory

/* IsDirectory * ---------------------------------------------------------------------------- */static BOOL IsDirectory(CString lpszName){    DWORD dwRet;    dwRet = GetFileAttributes(lpszName);    return (dwRet != 0xFFFFFFFF) && (dwRet & FILE_ATTRIBUTE_DIRECTORY);}
开发者ID:LM25TTD,项目名称:ATCMcontrol_Engineering,代码行数:9,


示例4: AddFile

int AddFile(wchar_t *fileName, wchar_t *path, int &index) {	index = 0;	if (!fileName || !fileName[0]) return -2;	wchar_t *name2 = wcsdup(fileName);	if (!name2) return -2;	int l = (int)wcslen(name2);	/*int pos = 0;	while (fileName[pos]) {		if (fileName[pos] == '/') fileName[pos] = '//'		l++;		pos++;	}//*/	if (fileName[0] == '<') {		if (fileName[l-1] != '>') {			return -2;		}		int l2 = 0;		if (path) l2 = (int)wcslen(path);		memcpy(name2, fileName+1, l * 2 - 4);		name2[l-2] = 0;		wchar_t *name = (wchar_t*) malloc(sizeof(wchar_t) * (l + 30));		if (name) {			wsprintf(name, L"Override//%s", name2);			if (GetFileAttributes(name) == INVALID_FILE_ATTRIBUTES) {				wsprintf(name, L"Include//%s", name2);			}			free(name2);			name2=name;			l = (int)wcslen(name2);		}		//wchar_t *test = ResolvePath(path, name2);	}	else {		if (fileName[0] == '/"') {			if (l<=3 || fileName[l-1] != '/"') {				free(name2);				return -2;			}			l-=2;			fileName++;			memcpy(name2, fileName, l * 2);			name2[l] = 0;		}		if (name2[1] != ':' && name2[0] != '//') {			wchar_t *w = wcsrchr(path, '//');			int l2 = 1+(int)(w - path);			if (!srealloc(name2, 2*(l2 + l + 2))) {				free(name2);				return -2;			}			memmove(name2 + l2, name2, 2*l+2);			memcpy(name2, path, 2*l2);			l+=l2+2;		}	}	int q = GetFullPathName(name2, 0, 0, 0);	wchar_t *nnew;	if (q<=0 || !(nnew = (wchar_t*) malloc(q*sizeof(wchar_t)))) {		free(name2);		return -2;	}	int q2 = GetFullPathName(name2, q, nnew, 0);	free(name2);	if (q2 <= 0 || q2 >= q) {		free(nnew);		return -2;	}	name2 = nnew;	q2 = GetLongPathName(nnew, 0, 0);	if (q2 > 0 && (nnew = (wchar_t*)malloc(q2*sizeof(wchar_t)))) {		if ((q = GetLongPathName(name2, nnew, q2)) >0 && q<q2) {			free(name2);			name2 = nnew;		}		else {			free(nnew);		}	}	/*	//name2 = ResolvePathSteal(name2);	if (name2[2] == '?') {		l = (int) wcslen(name2);		if (l < MAX_PATH+4)			memmove(name2, name2 + 4, 2*(l - 3));	}	int i = GetLongPathName(name2, 0, 0);	if (i <= 0 || !(fileName = (wchar_t*) malloc(i*2+2))) {		free(name2);		return -2;	}	int w = i;	i = GetLongPathName(name2, fileName, w);	free(name2);	if (i+1 != w) {		free(fileName);		return -2;	}//.........这里部分代码省略.........
开发者ID:ZmeyNet,项目名称:lcdmiscellany,代码行数:101,


示例5: MainDialog

// Message handler for the Main dialog boxLRESULT CALLBACK MainDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){	RECT rt;	HWND	hCurrentRadioButton;	wchar_t wdirname[MAX_PATH], msg[1024], *title;	int ret, valid, ntxns, written;	switch (message)	{		case WM_INITDIALOG:			// maximize the dialog.			GetClientRect(GetParent(hDlg), &rt);			SetWindowPos(hDlg, HWND_TOP, 0, 0, rt.right, rt.bottom,			    SWP_SHOWWINDOW);			CheckRadioButton(hDlg, IDC_MEDIUM_RADIO,			    IDC_SMALL_RADIO, IDC_SMALL_RADIO);			SetDlgItemText(hDlg, IDC_HOME_EDIT,			    tpcb->getHomeDirW(wdirname, MAX_PATH));			SetDlgItemInt(hDlg, IDC_TXN_EDIT, 1000, 0);			SetWindowText(hDlg, L"BDB TPCB Example app");			ShowWindow(hDlg, SW_SHOWNORMAL);			return TRUE;		case WM_COMMAND:			if (LOWORD(wParam) == IDC_INIT_BUTTON ||				LOWORD(wParam) == IDC_RUN_BUTTON ) {				hCurrentRadioButton = GetDlgItem(hDlg,				    IDC_SMALL_RADIO);				if(BST_CHECKED ==				    SendMessage(hCurrentRadioButton,				    BM_GETCHECK, NULL, NULL)) {					tpcb->accounts = 500;					tpcb->branches = 10;					tpcb->tellers  = 50;					tpcb->history  = 5000;				}				hCurrentRadioButton = GetDlgItem(hDlg,				    IDC_MEDIUM_RADIO);				if(BST_CHECKED ==				    SendMessage(hCurrentRadioButton,				    BM_GETCHECK, NULL, NULL)) {					tpcb->accounts = 1000;					tpcb->branches = 10;					tpcb->tellers  = 100;					tpcb->history  = 10000;				}				hCurrentRadioButton = GetDlgItem(hDlg,				    IDC_LARGE_RADIO);				if(BST_CHECKED ==				    SendMessage(hCurrentRadioButton,				    BM_GETCHECK, NULL, NULL)) {					tpcb->accounts = 100000;					tpcb->branches = 10;					tpcb->tellers  = 100;					tpcb->history  = 259200;				}				EnableWindow(GetDlgItem(hDlg, IDC_INIT_BUTTON),				    FALSE);				EnableWindow(GetDlgItem(hDlg, IDC_RUN_BUTTON),				    FALSE);				EnableWindow(GetDlgItem(hDlg, IDC_ADV_BUTTON),				    FALSE);			}			if (LOWORD(wParam) == IDC_ADV_BUTTON) {				CreateDialog(hInst,				    MAKEINTRESOURCE(IDD_ADVANCEDDIALOG), hDlg,				    (DLGPROC)AdvancedDialog);			} else if (LOWORD(wParam) == IDC_INIT_BUTTON) {				// Close the environment first.				// In case this is a re-initialization.				tpcb->closeEnv();				GetHomeDirectory(hDlg, TRUE);				tpcb->createEnv(0);				ret = tpcb->populate();			} else if (LOWORD(wParam) == IDC_RUN_BUTTON) {				GetHomeDirectory(hDlg, FALSE);				if (GetFileAttributes(				    tpcb->getHomeDirW(wdirname, MAX_PATH)) !=				    FILE_ATTRIBUTE_DIRECTORY) {					_snwprintf(msg, 1024,L"Target directory: %s does not exist, or is not a directory./nMake sure the "L"directory name is correct, and that you ran the initialization phase.",					    wdirname);					MessageBox(hDlg, msg, L"Error", MB_OK);					EnableWindow(GetDlgItem(hDlg,					    IDC_INIT_BUTTON), TRUE);					EnableWindow(GetDlgItem(hDlg,					    IDC_RUN_BUTTON), TRUE);					EnableWindow(GetDlgItem(hDlg,					    IDC_ADV_BUTTON), TRUE);					return FALSE;				}				// TODO: Check for an empty directory?				ntxns = GetDlgItemInt(hDlg, IDC_TXN_EDIT,				    &valid, FALSE);				if (valid == FALSE) {					MessageBox(hDlg,					L"Invalid number in transaction field.",					    L"Error", MB_OK);//.........这里部分代码省略.........
开发者ID:coapp-packages,项目名称:berkeleydb,代码行数:101,


示例6: StopBINDService

/* * User pressed the install button.  Make it go. */void CBINDInstallDlg::OnInstall() {#if _MSC_VER >= 1400	char Vcredist_x86[MAX_PATH];#endif	BOOL success = FALSE;	int oldlen;	if (CheckBINDService())		StopBINDService();	InstallTags();	UpdateData();	if (!m_toolsOnly && m_accountName != LOCAL_SERVICE) {		/*		 * Check that the Passwords entered match.		 */		if (m_accountPassword != m_accountPasswordConfirm) {			MsgBox(IDS_ERR_PASSWORD);			return;		}		/*		 * Check that there is not leading / trailing whitespace.		 * This is for compatibility with the standard password dialog.		 * Passwords really should be treated as opaque blobs.		 */		oldlen = m_accountPassword.GetLength();		m_accountPassword.TrimLeft();		m_accountPassword.TrimRight();		if (m_accountPassword.GetLength() != oldlen) {			MsgBox(IDS_ERR_WHITESPACE);			return;		}		/*		 * Check the entered account name.		 */		if (ValidateServiceAccount() == FALSE)			return;		/*		 * For Registration we need to know if account was changed.		 */		if (m_accountName != m_currentAccount)			m_accountUsed = FALSE;		if (m_accountUsed == FALSE && m_serviceExists == FALSE)		{		/*		 * Check that the Password is not null.		 */			if (m_accountPassword.GetLength() == 0) {				MsgBox(IDS_ERR_NULLPASSWORD);				return;			}		}	} else if (m_accountName == LOCAL_SERVICE) {		/* The LocalService always exists. */		m_accountExists = TRUE;		if (m_accountName != m_currentAccount)			m_accountUsed = FALSE;	}	/* Directories */	m_etcDir = m_targetDir + "//etc";	m_binDir = m_targetDir + "//bin";	if (m_defaultDir != m_targetDir) {		if (GetFileAttributes(m_targetDir) != 0xFFFFFFFF)		{			int install = MsgBox(IDS_DIREXIST,					MB_YESNO | MB_ICONQUESTION, m_targetDir);			if (install == IDNO)				return;		}		else {			int createDir = MsgBox(IDS_CREATEDIR,					MB_YESNO | MB_ICONQUESTION, m_targetDir);			if (createDir == IDNO)				return;		}	}	if (!m_toolsOnly) {		if (m_accountExists == FALSE) {			success = CreateServiceAccount(m_accountName.GetBuffer(30),							m_accountPassword.GetBuffer(30));			if (success == FALSE) {				MsgBox(IDS_CREATEACCOUNT_FAILED);				return;			}			m_accountExists = TRUE;		}	}//.........这里部分代码省略.........
开发者ID:donnerhacke,项目名称:bind9,代码行数:101,


示例7: replace

/*makes the replace*/INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore){	TCHAR d[MAX_PATH];	TCHAR s[MAX_PATH];	HANDLE hFileSrc, hFileDest;	DWORD  dwAttrib, dwRead, dwWritten;	LPBYTE buffer;	BOOL   bEof = FALSE;	FILETIME srcCreationTime, destCreationTime, srcLastAccessTime, destLastAccessTime;	FILETIME srcLastWriteTime, destLastWriteTime;	GetPathCase(source, s);	GetPathCase(dest, d);	s[0] = (TCHAR)_totupper(s[0]);	d[0] = (TCHAR)_totupper(d[0]);// 	ConOutPrintf(_T("old-src:  %s/n"), s);// 	ConOutPrintf(_T("old-dest: %s/n"), d);// 	ConOutPrintf(_T("src:  %s/n"), source);// 	ConOutPrintf(_T("dest: %s/n"), dest);	/* Open up the sourcefile */	hFileSrc = CreateFile (source, GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, 0, NULL);	if (hFileSrc == INVALID_HANDLE_VALUE)	{		ConOutResPrintf(STRING_COPY_ERROR1, source);		return 0;	}	/* Get the time from source file to be used in the comparison with	   dest time if update switch is set */	GetFileTime (hFileSrc, &srcCreationTime, &srcLastAccessTime, &srcLastWriteTime);	/* Retrieve the source attributes so that they later on can be	   inserted in to the destination */	dwAttrib = GetFileAttributes (source);	if(IsExistingFile (dest))	{		/* Resets the attributes to avoid probles with read only files,		   checks for read only has been made earlier */		SetFileAttributes(dest,FILE_ATTRIBUTE_NORMAL);		/* Is the update flas set? The time has to be controled so that		   only older files are replaced */		if(dwFlags & REPLACE_UPDATE)		{			/* Read destination time */			hFileDest = CreateFile(dest, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,				0, NULL);			if (hFileSrc == INVALID_HANDLE_VALUE)			{				ConOutResPrintf(STRING_COPY_ERROR1, dest);				return 0;			}			/* Compare time */			GetFileTime (hFileDest, &destCreationTime, &destLastAccessTime, &destLastWriteTime);			if(!((srcLastWriteTime.dwHighDateTime > destLastWriteTime.dwHighDateTime) ||					(	srcLastWriteTime.dwHighDateTime == destLastWriteTime.dwHighDateTime &&						srcLastWriteTime.dwLowDateTime > destLastWriteTime.dwLowDateTime)))			{				CloseHandle (hFileSrc);				CloseHandle (hFileDest);				return 0;			}			CloseHandle (hFileDest);		}		/* Delete the old file */		DeleteFile (dest);	}	/* Check confirm flag, and take appropriate action */	if(dwFlags & REPLACE_CONFIRM)	{		/* Output depending on add flag */		if(dwFlags & REPLACE_ADD)			ConOutResPrintf(STRING_REPLACE_HELP9, dest);		else			ConOutResPrintf(STRING_REPLACE_HELP10, dest);		if( !FilePromptYNA (0))			return 0;	}	/* Output depending on add flag */	if(dwFlags & REPLACE_ADD)		ConOutResPrintf(STRING_REPLACE_HELP11, dest);	else		ConOutResPrintf(STRING_REPLACE_HELP5, dest);	/* Make sure source and destination is not the same */	if(!_tcscmp(s, d))	{		ConOutResPaging(TRUE, STRING_REPLACE_ERROR7);		CloseHandle (hFileSrc);		*doMore = FALSE;		return 0;	}	/* Open destination file to write to */	hFileDest = CreateFile (dest, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);//.........这里部分代码省略.........
开发者ID:farp90,项目名称:nativecmd,代码行数:101,


示例8: return

BOOL CFileAndFolder::IsFolder(const CString& sPath){  return ((GetFileAttributes(sPath) & FILE_ATTRIBUTE_DIRECTORY) != 0);}
开发者ID:mikemakuch,项目名称:muzikbrowzer,代码行数:4,


示例9: SAFE_DELETE

//暗号化ファイルの解析CIPHER_RESULT PmCipher::ParseCipherFile(const char *cipher_path){	//
C++ GetFileAttributesA函数代码示例
C++ GetFieldENUMValue函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。