• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GetFileAttributes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了GetFileAttributes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:EditorMap.cpp


示例2: sl_file_exists

int
sl_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,代码来源:win32.c


示例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,代码来源:FolderDialog.cpp


示例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,代码来源:Script.cpp


示例5: MainDialog

// Message handler for the Main dialog box
LRESULT 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,代码来源:TpcbUI.cpp


示例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,代码来源:BINDInstallDlg.cpp


示例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,代码来源:replace.c


示例8: return

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


示例9: SAFE_DELETE

//暗号化ファイルの解析
CIPHER_RESULT PmCipher::ParseCipherFile(const char *cipher_path)
{
	//戻り値・・・ステータス
	//第1引数・・・暗号化ファイルのパス

	//ファイルプロパティ文字列
	char ch, str_size[10], *str_index, key_word[CIPHER_KEY_WORD_SIZE], cipher_key_word[CIPHER_KEY_WORD_SIZE];
	//戻り値
	CIPHER_RESULT cr = CIPHER_OK;
	//プロパティ一覧の解放(未解放時のための処理)
	SAFE_DELETE(m_property_list);
	
	//復号準備フラグOFF
	m_decrypt_init = false;
	//圧縮フラグOFF
	m_compress = false;

	//ファイルが存在しかつ、ディレクトリ属性ではない場合に処理開始
	if(PathFileExists(cipher_path) && !(GetFileAttributes(cipher_path) & FILE_ATTRIBUTE_DIRECTORY))
	{

		m_cipher_path = string(cipher_path);
		//暗号化ファイルのオープン
		m_fs_decrypt.open(cipher_path, ios::in|ios::binary);
		//キーワード読み込み
		m_fs_decrypt.read(cipher_key_word, CIPHER_KEY_WORD_SIZE);
		m_blow_fish.Decode((unsigned char *)cipher_key_word, (unsigned char *)key_word, CIPHER_KEY_WORD_SIZE);
		key_word[7] = '\0';
		if(strcmp(key_word, CIPHER_KEY_WORD))
		{
			DecryptEnd();
			return CIPHER_ERR_INVALID_FILE;
		}
		m_fs_decrypt.get(ch);
		//圧縮フラグ読み込み
		if(ch == '0')
		{
			m_compress = false;
		}
		else
		{
			m_compress = true;
		}
		//プロパティ一覧ファイルの元サイズ読み込み
		m_fs_decrypt.read(str_size, 10);
		m_current_source_size = AlphaToLong(str_size, 10);
		//プロパティ一覧ファイルの圧縮サイズ読み込み
		m_fs_decrypt.read(str_size, 10);
		m_current_compress_size = AlphaToLong(str_size, 10);
		//プロパティ一覧ファイルの暗号化サイズ読み込み
		m_fs_decrypt.read(str_size, 10);
		m_cipher_index_size = AlphaToLong(str_size, 10);
		m_current_cipher_size = m_cipher_index_size;
		m_fs_decrypt.read(str_size, 10);
		//平文受け取りバッファ
		char *buf;
		//サイズ等
		unsigned int size, buf_size, j;
		PmCipherProperty *cipher_property;
		m_total_buf_size = 0ul;
		m_total_decomp_buf_size = 0ul;
		m_decrypt_init = true;
		//ZLIBストリーム初期化
		if(m_compress)
		{
			m_z.zalloc = Z_NULL;
			m_z.zfree = Z_NULL;
			m_z.opaque = Z_NULL;
			if (inflateInit(&m_z) != Z_OK)
			{
				DecryptEnd();
				return CIPHER_ERR_INVALID_FILE;
			}
			m_z.avail_in = 0;
			m_z.avail_out = (unsigned int)(min(CIPHER_BUF_SIZE, m_current_source_size - m_total_buf_size));
			m_z.next_out = m_output_buf;
		}
		CIPHER_RESULT dec_cr;
		buf_size = 0;
		str_index = new char[m_current_source_size];
		//暗号化プロパティ一覧の復号完了までループ
		do
		{
			dec_cr = Decrypt(&buf, &size);
			memcpy(str_index + buf_size, buf, size);
			buf_size += size;
		}
		while(dec_cr == CIPHER_DEC_NEXT);
		char str_path[MAX_PATH];
		//プロパティ一覧の生成
		m_property_list = new PmCipherPropertyList();
		buf_size = 0;
		//ルートパスの取得
		j = 0;
		ZeroMemory(str_path, MAX_PATH);
		for(j = 0; buf_size + j < m_current_source_size && j < MAX_PATH; j++)
		{
			if(str_index[buf_size + j] == '\n')
			{
//.........这里部分代码省略.........
开发者ID:Ochakko,项目名称:e3dhsp3,代码行数:101,代码来源:PmCipher.cpp


示例10: recReplace

/* Function to iterate over source files and call replace for each of them */
INT recReplace(DWORD dwFlags, TCHAR szSrcPath[MAX_PATH], TCHAR szDestPath[MAX_PATH], BOOL *doMore)
{
	TCHAR tmpDestPath[MAX_PATH], tmpSrcPath[MAX_PATH];
	INT filesReplaced=0, i;
	DWORD dwAttrib = 0;
	HANDLE hFile;
	WIN32_FIND_DATA findBuffer;

	/* Get file handel to the sourcefile(s) */
	hFile = FindFirstFile (szSrcPath, &findBuffer);

	/* Strip the paths back to the folder they are in, so that the diffrent
	   filenames can be added if more than one */
	for(i = (_tcslen(szSrcPath) -  1); i > -1; i--)
		if(szSrcPath[i] != _T('\\'))
			szSrcPath[i] = _T('\0');
		else
			break;

	/* Go through all the soursfiles and copy/replace them */
	do
	{
		if(CheckCtrlBreak(BREAK_INPUT))
		{
			return filesReplaced;
		}

		/* Problem with file handler */
		if(hFile == INVALID_HANDLE_VALUE)
			return filesReplaced;

		/* We do not want to replace any .. . ocr directory */
		if(!_tcscmp (findBuffer.cFileName, _T("."))  ||
				!_tcscmp (findBuffer.cFileName, _T(".."))||
				findBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				continue;

		/* Add filename to destpath */
		_tcscpy(tmpDestPath,szDestPath);
		_tcscat (tmpDestPath, findBuffer.cFileName);

		dwAttrib = GetFileAttributes(tmpDestPath);
		/* Check add flag */
		if(dwFlags & REPLACE_ADD)
		{
			if(IsExistingFile(tmpDestPath))
				continue;
			else
				dwAttrib = 0;
		}
		else
		{
			if(!IsExistingFile(tmpDestPath))
				continue;
		}

		/* Check if file is read only, if so check if that should be ignored */
		if(dwAttrib & FILE_ATTRIBUTE_READONLY)
		{
			if(!(dwFlags & REPLACE_READ_ONLY))
			{
				ConOutResPrintf(STRING_REPLACE_ERROR5, tmpDestPath);
				*doMore = FALSE;
				break;
			}
		}

		/* Add filename to sourcepath, insted of wildcards */
		_tcscpy(tmpSrcPath,szSrcPath);
		_tcscat (tmpSrcPath, findBuffer.cFileName);

		/* Make the replace */
		if(replace(tmpSrcPath,tmpDestPath, dwFlags, doMore))
		{
			filesReplaced++;
		}
		else if (!*doMore)
		{
			/* The file to be replaced was the same as the source */
			filesReplaced = -1;
			break;
		}

	/* Take next sourcefile if any */
	}while(FindNextFile (hFile, &findBuffer));

	return filesReplaced;
}
开发者ID:farp90,项目名称:nativecmd,代码行数:89,代码来源:replace.c


示例11: return

BOOL CTreeFileCtrl::IsFile(const CString& sPath)
{
  return ((GetFileAttributes(sPath) & FILE_ATTRIBUTE_DIRECTORY) == 0);
}
开发者ID:5432935,项目名称:genesis3d,代码行数:4,代码来源:FileTreeCtrl.cpp


示例12: copy

INT
copy(TCHAR source[MAX_PATH],
     TCHAR dest[MAX_PATH],
     INT append,
     DWORD lpdwFlags,
     BOOL bTouch)
{
    FILETIME srctime,NewFileTime;
    HANDLE hFileSrc;
    HANDLE hFileDest;
    LPBYTE buffer;
    DWORD  dwAttrib;
    DWORD  dwRead;
    DWORD  dwWritten;
    BOOL   bEof = FALSE;
    TCHAR TrueDest[MAX_PATH];
    TCHAR TempSrc[MAX_PATH];
    TCHAR * FileName;
    SYSTEMTIME CurrentTime;

    /* Check Breaker */
    if (CheckCtrlBreak(BREAK_INPUT))
        return 0;

    TRACE ("checking mode\n");

    if (bTouch)
    {
        hFileSrc = CreateFile (source, GENERIC_WRITE, FILE_SHARE_READ,
            NULL, OPEN_EXISTING, 0, NULL);
        if (hFileSrc == INVALID_HANDLE_VALUE)
        {
            ConOutResPrintf(STRING_COPY_ERROR1, source);
            nErrorLevel = 1;
            return 0;
        }

        GetSystemTime(&CurrentTime);
        SystemTimeToFileTime(&CurrentTime, &NewFileTime);
        if (SetFileTime(hFileSrc,(LPFILETIME) NULL, (LPFILETIME) NULL, &NewFileTime))
        {
            CloseHandle(hFileSrc);
            nErrorLevel = 1;
            return 1;

        }
        else
        {
            CloseHandle(hFileSrc);
            return 0;
        }
    }

    dwAttrib = GetFileAttributes (source);

    hFileSrc = CreateFile (source, GENERIC_READ, FILE_SHARE_READ,
        NULL, OPEN_EXISTING, 0, NULL);
    if (hFileSrc == INVALID_HANDLE_VALUE)
    {
        ConOutResPrintf(STRING_COPY_ERROR1, source);
        nErrorLevel = 1;
        return 0;
    }

    TRACE ("getting time\n");

    GetFileTime (hFileSrc, &srctime, NULL, NULL);

    TRACE ("copy: flags has %s\n",
        lpdwFlags & COPY_ASCII ? "ASCII" : "BINARY");

    /* Check to see if /D or /Z are true, if so we need a middle
       man to copy the file too to allow us to use CopyFileEx later */
    if (lpdwFlags & COPY_DECRYPT)
    {
        GetEnvironmentVariable(_T("TEMP"),TempSrc,MAX_PATH);
        _tcscat(TempSrc,_T("\\"));
        FileName = _tcsrchr(source,_T('\\'));
        FileName++;
        _tcscat(TempSrc,FileName);
        /* This is needed to be on the end to prevent an error
           if the user did "copy /D /Z foo bar then it would be copied
           too %TEMP%\foo here and when %TEMP%\foo when it sets it up
           for COPY_RESTART, this would mean it is copying to itself
           which would error when it tried to open the handles for ReadFile
           and WriteFile */
        _tcscat(TempSrc,_T(".decrypt"));
        if (!CopyFileEx(source, TempSrc, NULL, NULL, FALSE, COPY_FILE_ALLOW_DECRYPTED_DESTINATION))
        {
            CloseHandle (hFileSrc);
            nErrorLevel = 1;
            return 0;
        }
        _tcscpy(source, TempSrc);
    }


    if (lpdwFlags & COPY_RESTART)
    {
        _tcscpy(TrueDest, dest);
//.........这里部分代码省略.........
开发者ID:hoangduit,项目名称:reactos,代码行数:101,代码来源:copy.c


示例13: DoesFileExist

bool DoesFileExist(const CString& name)
   {
   return (GetFileAttributes(name.GetString()) == 0xffffffff) ? false : true;
   }
开发者ID:aisnote,项目名称:camstudio-clone,代码行数:4,代码来源:CamFile.cpp


示例14: ASSERT

// ---------------------------------------------------------------------------
// CEnumCache::GetNextAssemblyDir
// ---------------------------------------------------------------------------
HRESULT
CEnumCache::GetNextAssemblyDir(CTransCache* pOutRecord)
{
    HRESULT hr = S_FALSE;
    DWORD dwCmpResult = 0;
    BOOL fIsMatch = FALSE;
    BOOL fFound = FALSE;
    WIN32_FIND_DATA FindFileData;
    WCHAR           wzFullSearchPath[MAX_PATH+1];
    DWORD dwAttr=0;
    WCHAR wzFullPath[MAX_PATH+1];
    DWORD dwCacheType=0;

    if( !pOutRecord )
    {
        hr = E_INVALIDARG;
        goto exit;
    }

    if(_fAllDone)
    {
        hr = S_FALSE;
        goto exit;
    }

    ASSERT(lstrlenW(_wzParentDir));

    if(_hAsmDir == INVALID_HANDLE_VALUE)
    {
        if( (lstrlenW(_wzCachePath) + lstrlenW(_wzParentDir) + lstrlenW(g_szFindAllMask) + 4) >= MAX_PATH)
        {
            hr = HRESULT_FROM_WIN32(FUSION_E_INVALID_NAME);
            goto exit;
        }

        StrCpy(wzFullSearchPath, _wzCachePath);
        PathAddBackslash(wzFullSearchPath);
        StrCat(wzFullSearchPath, _wzParentDir);

        dwAttr = GetFileAttributes(wzFullSearchPath);
        if((dwAttr == (DWORD) -1) || !(dwAttr & FILE_ATTRIBUTE_DIRECTORY ))
        {
            hr = S_FALSE;
            goto exit;
        }

        StrCat(wzFullSearchPath, g_szFindAllMask);
        
        _hAsmDir = FindFirstFile(wzFullSearchPath, &FindFileData);

        if(_hAsmDir == INVALID_HANDLE_VALUE)
        {
            hr = FusionpHresultFromLastError();
            goto exit;
        }

        fFound = TRUE;
    }
    else
    {   
        if(FindNextFile(_hAsmDir, &FindFileData))
            fFound = TRUE;
    }

    do
    {
        if(!fFound)
            break;

        if (!StrCmp(FindFileData.cFileName, L"."))
                continue;

        if (!StrCmp(FindFileData.cFileName, L".."))
                continue;

        if (!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
            continue;

        hr = ParseDirName ( pOutRecord, _wzParentDir, FindFileData.cFileName );
        if(hr != S_OK)
        {
            pOutRecord->CleanInfo(pOutRecord->_pInfo, TRUE);
            continue;
        }

        if( (lstrlenW(_wzCachePath) + lstrlenW(_wzParentDir) + lstrlenW(FindFileData.cFileName) + 4) >= MAX_PATH)
        {
            hr = HRESULT_FROM_WIN32(FUSION_E_INVALID_NAME);
            goto exit;
        }

        StrCpy(wzFullPath, _wzCachePath);
        PathAddBackslash(wzFullPath);
        StrCat(wzFullPath, _wzParentDir);
        PathAddBackslash(wzFullPath);
        StrCat(wzFullPath, FindFileData.cFileName);

//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:enum.cpp


示例15: fexists

bool fexists(string f)
{
	return (GetFileAttributes(f.c_str()) != 0xFFFFFFFF);
}
开发者ID:DeezNuts12,项目名称:freestyledash,代码行数:4,代码来源:FileBrowser.cpp


示例16: InUn

static BOOL
InUn(int remove, char *drivername, char *dllname, char *dll2name, char *dsname)
{
    char path[301], driver[300], attr[300], inst[400], inst2[400];
    WORD pathmax = sizeof (path) - 1, pathlen;
    DWORD usecnt, mincnt;

    if (SQLInstallDriverManager(path, pathmax, &pathlen)) {
	char *p;

	sprintf(driver, "%s;Driver=%s;Setup=%s;",
		drivername, dllname, dllname);
	p = driver;
	while (*p) {
	    if (*p == ';') {
		*p = '\0';
	    }
	    ++p;
	}
	usecnt = 0;
	SQLInstallDriverEx(driver, NULL, path, pathmax, &pathlen,
			   ODBC_INSTALL_INQUIRY, &usecnt);
	sprintf(driver, "%s;Driver=%s\\%s;Setup=%s\\%s;",
		drivername, path, dllname, path, dllname);
	p = driver;
	while (*p) {
	    if (*p == ';') {
		*p = '\0';
	    }
	    ++p;
	}
	sprintf(inst, "%s\\%s", path, dllname);
	if (dll2name) {
	    sprintf(inst2, "%s\\%s", path, dll2name);
	}
	if (!remove && usecnt > 0) {
	    /* first install try: copy over driver dll, keeping DSNs */
	    if (GetFileAttributes(dllname) != INVALID_FILE_ATTRIBUTES &&
		CopyFile(dllname, inst, 0) &&
		CopyOrDelModules(dllname, path, 0)) {
		if (dll2name != NULL) {
		    CopyFile(dll2name, inst2, 0);
		}
		return TRUE;
	    }
	}
	mincnt = remove ? 1 : 0;
	while (usecnt != mincnt) {
	    if (!SQLRemoveDriver(driver, TRUE, &usecnt)) {
		break;
	    }
	}
	if (remove) {
	    if (!SQLRemoveDriver(driver, TRUE, &usecnt)) {
		ProcessErrorMessages("SQLRemoveDriver");
		return FALSE;
	    }
	    if (!usecnt) {
		char buf[512];

		DeleteFile(inst);
		/* but keep inst2 */
		CopyOrDelModules(dllname, path, 1);
		if (!quiet) {
		    sprintf(buf, "%s uninstalled.", drivername);
		    MessageBox(NULL, buf, "Info",
			       MB_ICONINFORMATION|MB_OK|MB_TASKMODAL|
			       MB_SETFOREGROUND);
		}
	    }
	    if (nosys) {
		goto done;
	    }
	    sprintf(attr, "DSN=%s;", dsname);
	    p = attr;
	    while (*p) {
		if (*p == ';') {
		    *p = '\0';
		}
		++p;
	    }
	    SQLConfigDataSource(NULL, ODBC_REMOVE_SYS_DSN, drivername, attr);
	    goto done;
	}
	if (GetFileAttributes(dllname) == INVALID_FILE_ATTRIBUTES) {
	    return FALSE;
	}
	if (!CopyFile(dllname, inst, 0)) {
	    char buf[512];

	    sprintf(buf, "Copy %s to %s failed", dllname, inst);
	    MessageBox(NULL, buf, "CopyFile",
		       MB_ICONSTOP|MB_OK|MB_TASKMODAL|MB_SETFOREGROUND); 
	    return FALSE;
	}
	if (dll2name != NULL && !CopyFile(dll2name, inst2, 0)) {
	    char buf[512];

	    sprintf(buf, "Copy %s to %s failed", dll2name, inst2);
	    MessageBox(NULL, buf, "CopyFile",
//.........这里部分代码省略.........
开发者ID:lessc0de,项目名称:sqliteodbc,代码行数:101,代码来源:inst.c


示例17: GetCurrentPath

string FileBrowser::mGetFileFTPLongDescription(string file)
{
	string out = "";

	struct stat statFileStatus;
	string fullFilePath = GetCurrentPath() + "\\" + file;
	stat(fullFilePath.c_str(),&statFileStatus);
		
		
	DWORD attr = GetFileAttributes(fullFilePath.c_str());
	char execute = 'x';
	char read = 'r';
	char write = 'w';
	char directory = '-';
	if(attr&FILE_ATTRIBUTE_DIRECTORY)
	{
		directory = '-';
		directory = 'd';
	}
	if(attr&FILE_ATTRIBUTE_ARCHIVE )
	{
		execute = '-';
	}
	if(attr&FILE_ATTRIBUTE_READONLY  )
	{
		write = '-';
	}
	if(attr&FILE_ATTRIBUTE_DEVICE   )
	{
		read = '-';
	}
	char timeStr[ 100 ] = "";
	struct tm locTime;
	int retval = localtime_s(&locTime, &statFileStatus.st_mtime);
	if(retval)
	{
		retval = localtime_s(&locTime, &statFileStatus.st_atime);
	}
	if(retval)
	{
		retval = localtime_s(&locTime, &statFileStatus.st_ctime);
	}
	if(retval)
	{
		time_t t;
		time(&t);
		retval = localtime_s(&locTime, &t);
	}

/*	SYSTEMTIME stCutoff;
	GetSystemTime(&stCutoff);
	stCutoff.wYear--;

	if (locTime.tm_year+1900 > stCutoff.wYear || 
		(locTime.tm_year+1900 == stCutoff.wYear && locTime.tm_mon > stCutoff.wMonth) ||
		(locTime.tm_year+1900 == stCutoff.wYear && locTime.tm_mon == stCutoff.wMonth && locTime.tm_mday > stCutoff.wDay)) {
		strftime(timeStr, 100, "%b %d %Y",  &locTime);
	}
	else {*/
		strftime(timeStr, 100, "%b %d %H:%M",  &locTime);
//	}

	out= sprintfa("%c%c%c%c%c%c%c%c%c%c   1 root  root    %d %s %s\r\n",directory,read,write,execute,read,write,execute,read,write,execute,statFileStatus.st_size,timeStr,file.c_str());
	return out;
}
开发者ID:DeezNuts12,项目名称:freestyledash,代码行数:65,代码来源:FileBrowser.cpp


示例18: TestplatformChmod


//.........这里部分代码省略.........
		getSecurityDescriptorDaclProc = (getSecurityDescriptorDaclDef)
			GetProcAddress(hInstance, "GetSecurityDescriptorDacl");
		lookupAccountNameProc = (lookupAccountNameADef)
			GetProcAddress(hInstance, "LookupAccountNameA");
		getSidLengthRequiredProc = (getSidLengthRequiredDef)
			GetProcAddress(hInstance, "GetSidLengthRequired");
		initializeSidProc = (initializeSidDef)
			GetProcAddress(hInstance, "InitializeSid");
		getSidSubAuthorityProc = (getSidSubAuthorityDef)
			GetProcAddress(hInstance, "GetSidSubAuthority");

		if (setNamedSecurityInfoProc && getAceProc && addAceProc
			&& equalSidProc && addAccessDeniedAceProc
			&& initializeAclProc && getLengthSidProc
			&& getAclInformationProc
			&& getSecurityDescriptorDaclProc
			&& lookupAccountNameProc && getFileSecurityProc
			&& getSidLengthRequiredProc && initializeSidProc
			&& getSidSubAuthorityProc) {
		    initialized = 1;
		}
	    }
	    if (!initialized) {
		initialized = -1;
	    }
	}
	Tcl_MutexUnlock(&initializeMutex);
    }

    /*
     * Process the chmod request.
     */

    attr = GetFileAttributes(nativePath);

    /*
     * nativePath not found
     */

    if (attr == 0xffffffff) {
	res = -1;
	goto done;
    }

    /*
     * If no ACL API is present or nativePath is not a directory, there is no
     * special handling.
     */

    if (initialized < 0 || !(attr & FILE_ATTRIBUTE_DIRECTORY)) {
	goto done;
    }

    /*
     * Set the result to error, if the ACL change is successful it will be
     * reset to 0.
     */

    res = -1;

    /*
     * Read the security descriptor for the directory. Note the first call
     * obtains the size of the security descriptor.
     */

    if (!getFileSecurityProc(nativePath, infoBits, NULL, 0, &secDescLen)) {
开发者ID:AbaqusPowerUsers,项目名称:AbaqusPythonScripts,代码行数:67,代码来源:tclWinTest.c


示例19: SHGetMalloc

void CBINDInstallDlg::ProgramGroup(BOOL create) {
	TCHAR path[MAX_PATH], commonPath[MAX_PATH], fileloc[MAX_PATH], linkpath[MAX_PATH];
	HRESULT hres;
	IShellLink *psl = NULL;
	LPMALLOC pMalloc = NULL;
	ITEMIDLIST *itemList = NULL;

	HRESULT hr = SHGetMalloc(&pMalloc);
	if (hr != NOERROR) {
		MessageBox("Could not get a handle to Shell memory object");
		return;
	}

	hr = SHGetSpecialFolderLocation(m_hWnd, CSIDL_COMMON_PROGRAMS, &itemList);
	if (hr != NOERROR) {
		MessageBox("Could not get a handle to the Common Programs folder");
		if (itemList) {
			pMalloc->Free(itemList);
		}
		return;
	}

	hr = SHGetPathFromIDList(itemList, commonPath);
	pMalloc->Free(itemList);

	if (create) {
		sprintf(path, "%s\\ISC", commonPath);
		CreateDirectory(path, NULL);

		sprintf(path, "%s\\ISC\\BIND", commonPath);
		CreateDirectory(path, NULL);

		hres = CoInitialize(NULL);

		if (SUCCEEDED(hres)) {
			// Get a pointer to the IShellLink interface.
			hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
			if (SUCCEEDED(hres))
			{
				IPersistFile* ppf;
				sprintf(linkpath, "%s\\BINDCtrl.lnk", path);
				sprintf(fileloc, "%s\\BINDCtrl.exe", m_binDir);

				psl->SetPath(fileloc);
				psl->SetDescription("BIND Control Panel");

				hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
				if (SUCCEEDED(hres)) {
					WCHAR wsz[MAX_PATH];

					MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH);
					hres = ppf->Save(wsz, TRUE);
					ppf->Release();
				}

				if (GetFileAttributes("readme.txt") != -1) {
					sprintf(fileloc, "%s\\Readme.txt", m_targetDir);
					sprintf(linkpath, "%s\\Readme.lnk", path);

					psl->SetPath(fileloc);
					psl->SetDescription("BIND Readme");

					hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
					if (SUCCEEDED(hres)) {
						WCHAR wsz[MAX_PATH];

						MultiByteToWideChar(CP_ACP, 0, linkpath, -1, wsz, MAX_PATH);
						hres = ppf->Save(wsz, TRUE);
						ppf->Release();
					}
					psl->Release();
				}
			}
			CoUninitialize();
		}
	}
	else {
		TCHAR filename[MAX_PATH];
		WIN32_FIND_DATA fd;

		sprintf(path, "%s\\ISC\\BIND", commonPath);

		sprintf(filename, "%s\\*.*", path);
		HANDLE hFind = FindFirstFile(filename, &fd);
		if (hFind != INVALID_HANDLE_VALUE) {
			do {
				if (strcmp(fd.cFileName, ".") && strcmp(fd.cFileName, "..")) {
					sprintf(filename, "%s\\%s", path, fd.cFileName);
					DeleteFile(filename);
				}
			} while (FindNextFile(hFind, &fd));
			FindClose(hFind);
		}
		RemoveDirectory(path);
		sprintf(path, "%s\\ISC", commonPath);
		RemoveDirectory(path);
	}
}
开发者ID:donnerhacke,项目名称:bind9,代码行数:98,代码来源:BINDInstallDlg.cpp


示例20: _tsearchenv_s

/*********************************************************************
 *		_searchenv_s ([email protected])
 */
int _tsearchenv_s(const _TCHAR* file, const _TCHAR* env, _TCHAR *buf, size_t count)
{
  _TCHAR *envVal, *penv;
  _TCHAR curPath[MAX_PATH];

  if (!MSVCRT_CHECK_PMT(file != NULL) || !MSVCRT_CHECK_PMT(buf != NULL) ||
      !MSVCRT_CHECK_PMT(count > 0))
  {
      *_errno() = EINVAL;
      return EINVAL;
  }

  *buf = '\0';

  /* Try CWD first */
  if (GetFileAttributes( file ) != INVALID_FILE_ATTRIBUTES)
  {
    GetFullPathName( file, MAX_PATH, buf, NULL );
    _dosmaperr(GetLastError());
    return 0;
  }

  /* Search given environment variable */
  envVal = _tgetenv(env);
  if (!e 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetFileAttributesA函数代码示例发布时间:2022-05-30
下一篇:
C++ GetFieldENUMValue函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap