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

C++ GetFileAttributesA函数代码示例

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

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



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

示例1: knh_exists

kbool_t knh_exists(CTX ctx, const char *fname)
{
	kbool_t res = 0;
	if(fname == NULL || fname[0] == 0) return 0;
#if defined(K_USING_WINDOWS_)
	DWORD attr = GetFileAttributesA(fname);
	res = (attr != -1);
#elif defined(K_USING_POSIX_)
	struct stat buf;
	res = (stat(fname, &buf) != -1);
#else
#endif
	if(res == 0) {
		DBG_P("'%s' NOTFOUND", fname);
	}
	return res;
}
开发者ID:imasahiro,项目名称:konohascript,代码行数:17,代码来源:os.c


示例2: FSExistDirectory

bool FSExistDirectory(const char *dirName)
{
#if defined(_WIN32_WCE)
	return FSExistDirectory( UniString(dirName) );
#elif defined(WIN32) 

	if ( dirName == NULL ) return false;
	if ( *dirName == 0 ) return false;

	DWORD attr = GetFileAttributesA(dirName);
	return ((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY));
	
#else
	UniString	uniString(dirName);
	return FSExistDirectory(uniString);
#endif
}
开发者ID:kjoon010,项目名称:IncubeTech-Contribs,代码行数:17,代码来源:FileSystem.cpp


示例3: knh_path_isdir

knh_bool_t knh_path_isdir(CTX ctx, knh_path_t *ph)
{
	const char *pname = P_text(ph) + ph->pbody;
	if(pname[0] == 0) return 0;
#if defined(K_USING_WINDOWS)
	DWORD attr = GetFileAttributesA(pname);
	if(attr == -1) return 0;
	return ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
#elif defined(K_USING_POSIX_)
	struct stat buf;
	if(stat(pname, &buf) == -1) return 0;
	return S_ISDIR(buf.st_mode);
#else
	// avoid "unused variable" warning unused variable
	(void)phname;
	return 0;
#endif
}
开发者ID:shinpei,项目名称:konoha-wand,代码行数:18,代码来源:os.c


示例4: __win_fs_exist

/*
 * __win_fs_exist --
 *	Return if the file exists.
 */
static int
__win_fs_exist(WT_FILE_SYSTEM *file_system,
    WT_SESSION *wt_session, const char *name, bool *existp)
{
	WT_DECL_RET;
	WT_SESSION_IMPL *session;

	WT_UNUSED(file_system);

	session = (WT_SESSION_IMPL *)wt_session;

	if (GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES)
		*existp = true;
	else
		*existp = false;

	return (0);
}
开发者ID:GYGit,项目名称:mongo,代码行数:22,代码来源:os_fs.c


示例5: sqlite3WinFileExists

/*
** Return TRUE if the named file exists.
*/
int sqlite3WinFileExists(const char *zFilename){
  int exists = 0;
  void *zConverted = convertUtf8Filename(zFilename);
  if( zConverted==0 ){
    return SQLITE_NOMEM;
  }
  if( isNT() ){
    exists = GetFileAttributesW((WCHAR*)zConverted) != 0xffffffff;
  }else{
#if OS_WINCE
    return SQLITE_NOMEM;
#else
    exists = GetFileAttributesA((char*)zConverted) != 0xffffffff;
#endif
  }
  sqliteFree(zConverted);
  return exists;
}
开发者ID:bazhenovc,项目名称:nebula3,代码行数:21,代码来源:os_win.c


示例6: __declspec

extern "C" __declspec(dllexport) bool ApplyPatchSuspended(HANDLE hProcess, DWORD)
{
  // Get target file name
  char szTarget[MAX_PATH];
  strncpy(szTarget, GetBWAPITarget().c_str(), MAX_PATH-1);
  szTarget[MAX_PATH-1] = '\0';

  // Check if the file exists, INVALID_FILE_ATTRIBUTES will have this bit set too
  if ( GetFileAttributesA(GetBWAPITarget().c_str()) & FILE_ATTRIBUTE_DIRECTORY )
    return BWAPIError("Unable to find %s.", szTarget);

  // Get the address for the LoadLibrary procedure
  HMODULE hKernalModule = GetModuleHandle(L"Kernel32");
  if ( !hKernalModule )
    return BWAPIError("Unable to get module handle for Kernel32.");

  LPTHREAD_START_ROUTINE loadLibAddress = (LPTHREAD_START_ROUTINE)GetProcAddress(hKernalModule, "LoadLibraryA" );
  if ( !loadLibAddress )
    return BWAPIError("Could not get Proc Address for LoadLibraryA.");

  // Create a remote allocation
  VAlloc alloc(hProcess, MAX_PATH);
  if ( !alloc )
    return BWAPIError("Could not allocate memory for DLL path.");

  // Write the DLL path to the allocation
  if ( !alloc.Write(szTarget, MAX_PATH) )
    return BWAPIError("Write process memory failed.");

  // Create a remote thread for LoadLibrary and pass the DLL path as a parameter
  RemoteThread thread(hProcess, loadLibAddress, alloc.GetAddress());
  if ( !thread )
    return BWAPIError("Unable to create remote thread.");

  // Wait for the thread to finish
  if ( !thread.Wait() )
    return BWAPIError("WaitForSingleObject failed.");

  // The exit code for LoadLibrary is its return value, if it's NULL then loading failed
  if ( thread.GetExitCode() == NULL )
    return BWAPIError("Injection failed.\nThis is caused when BWAPI crashes before injecting completely.");

  return true; //everything OK
}
开发者ID:dansgithubuser,项目名称:ninepool,代码行数:44,代码来源:chaoslauncher.cpp


示例7: CheckFileExistsInProgramGroups

/* Check for Existence (or non-existence) of a file or group
 *   When testing for existence of a group, groupName is not needed
 */
static void CheckFileExistsInProgramGroups(const char *nameToCheck, BOOL shouldExist, BOOL isGroup,
                                           const char *groupName, int testParams)
{
    char path[MAX_PATH];
    DWORD attributes;
    int len;

    lstrcpyA(path, ProgramsDir);

    len = strlen(path) + strlen(nameToCheck)+1;
    if (groupName != NULL)
    {
        len += strlen(groupName)+1;
    }
    ok (len <= MAX_PATH, "Path Too Long.%s\n", GetStringFromTestParams(testParams));
    if (len <= MAX_PATH)
    {
        if (groupName != NULL)
        {
            strcat(path, "\\");
            strcat(path, groupName);
        }
        strcat(path, "\\");
        strcat(path, nameToCheck);
        attributes = GetFileAttributesA(path);
        if (!shouldExist)
        {
            ok (attributes == INVALID_FILE_ATTRIBUTES , "File exists and shouldn't %s.%s\n",
                path, GetStringFromTestParams(testParams));
        } else {
            if (attributes == INVALID_FILE_ATTRIBUTES)
            {
                ok (FALSE, "Created File %s doesn't exist.%s\n", path, GetStringFromTestParams(testParams));
            } else if (isGroup) {
                ok (attributes & FILE_ATTRIBUTE_DIRECTORY, "%s is not a folder (attr=%x).%s\n",
                    path, attributes, GetStringFromTestParams(testParams));
            } else {
                ok (attributes & FILE_ATTRIBUTE_ARCHIVE, "Created File %s has wrong attributes (%x).%s\n",
                    path, attributes, GetStringFromTestParams(testParams));
            }
        }
    }
}
开发者ID:AmesianX,项目名称:wine,代码行数:46,代码来源:progman_dde.c


示例8: FSExistFile

bool FSExistFile(const char *fileName)
{
#if defined(_WIN32_WCE)
	return (GetFileAttributes(UniString(fileName)) != INVALID_FILE_ATTRIBUTES);
#elif defined(WIN32) 

	if ( fileName == NULL ) return false;
	if ( *fileName == 0 ) return false;

//	return PathFileExistsA(fileName);
	return (GetFileAttributesA(fileName) != INVALID_FILE_ATTRIBUTES);
//	return _access(fileName, 0) == 0;
#else

	UniString	uniString(fileName);
	return FSExistFile(uniString);

#endif
}
开发者ID:kjoon010,项目名称:IncubeTech-Contribs,代码行数:19,代码来源:FileSystem.cpp


示例9: PDLASSERT

BOOL PDLAPI LFile::Exists(
    __in PCSTR lpszFileName,
    __in BOOL bIncludeDir)
{
    PDLASSERT(NULL != lpszFileName);
#ifndef _WIN32_WCE
    DWORD dwAttr = GetFileAttributesA(lpszFileName);
    if (INVALID_FILE_ATTRIBUTES == dwAttr)
        return FALSE;

    if (bIncludeDir)
        return TRUE;
    else
        return 0 == (FILE_ATTRIBUTE_DIRECTORY & dwAttr);
#else
    LStringW str = lpszFileName;
    return Exists(str);
#endif // _WIN32_WCE
}
开发者ID:lvtx,项目名称:pdl-titilima,代码行数:19,代码来源:file.cpp


示例10: fileExists

////////////////////////////////////////////////////////////////////////////////////
///
///   \param filename The file to check for.
///
///   \return True 1 if the file exists, otherwise 0.
///
////////////////////////////////////////////////////////////////////////////////////
int FileIO::fileExists(const char * filename)
{
    int result = false;

#ifdef WIN32
    if (GetFileAttributesA(filename) != /*INVALID_FILE_ATTRIBUTES*/ -1)
    {
        result = true;
    }
#else
    FILE * file = fopen(filename, "rb");
    if (file)
    {
        fclose(file);
        result = true;
    }
#endif

    return result;
}
开发者ID:rwoodley,项目名称:FaceToys,代码行数:27,代码来源:fileio.cpp


示例11: GetFileAttributesA

//------------------------------------------//
// FileHelper::CheckFolderExists				
//------------------------------------------//
bool FileHelper::CheckFolderExists(const std::string& pDirectory)
{
	//http://stackoverflow.com/questions/8233842/how-to-check-if-directory-exist-using-c-and-winapi
#if __WINDOWS__

	DWORD ftyp = GetFileAttributesA(pDirectory.c_str());
	if (ftyp == INVALID_FILE_ATTRIBUTES)
	{
		return false;  //something is wrong with your path!
	}

	if (ftyp & FILE_ATTRIBUTE_DIRECTORY)
	{
		return true;   // this is a directory!
	}

#endif

	return false;
}
开发者ID:TaintedGear,项目名称:GameFramework,代码行数:23,代码来源:FileHelper.cpp


示例12: dirExists

bool dirExists(const std::string& dirName)
{
#ifdef _WIN32
  DWORD ftyp = GetFileAttributesA(dirName.c_str());
  if (ftyp == INVALID_FILE_ATTRIBUTES)
    return false;  //something is wrong with your path!

  if (ftyp & FILE_ATTRIBUTE_DIRECTORY)
    return true;   // this is a directory!
#else
  struct stat sb;

  if (stat(dirName.c_str(), &sb)==0 && S_ISDIR(sb.st_mode))
  {
    return true;
  }
#endif

  return false;
}
开发者ID:Constellation,项目名称:doxygen,代码行数:20,代码来源:doxysearch.cpp


示例13: mpqapi_set_hidden

bool __fastcall mpqapi_set_hidden(char *pszArchive, bool hidden)
{
	char *v2; // edi
	BOOL v3; // esi
	DWORD v4; // eax
	bool result; // al
	DWORD v6; // esi

	v2 = pszArchive;
	v3 = hidden;
	v4 = GetFileAttributesA(pszArchive);
	if ( v4 == -1 )
		return GetLastError() == ERROR_FILE_NOT_FOUND;
	v6 = v3 != 0 ? FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN : 0;
	if ( v4 == v6 )
		result = 1;
	else
		result = SetFileAttributesA(v2, v6);
	return result;
}
开发者ID:Alim-Oezdemir,项目名称:devilution,代码行数:20,代码来源:mpqapi.cpp


示例14: GetFileAttr

uint GetFileAttr(const char *Name,const wchar *NameW)
{
#ifdef _WIN_ALL
    if (WinNT() && NameW!=NULL && *NameW!=0)
      return(GetFileAttributesW(NameW));
    else
      return(GetFileAttributesA(Name));
#elif defined(_DJGPP)
  return(_chmod(Name,0));
#else
  struct stat st;
  if (stat(Name,&st)!=0)
    return(0);
#ifdef _EMX
  return(st.st_attr);
#else
  return(st.st_mode);
#endif
#endif
}
开发者ID:ajnelson,项目名称:bulk_extractor,代码行数:20,代码来源:filefn.cpp


示例15: af_IsFileExist

// Check if a specified file exist
bool af_IsFileExist(const char * szRelativePath)
{
	// we must supply a relative path to GetFilePck function
	AFilePackage * pPackage = g_AFilePackMan.GetFilePck(szRelativePath);
	if( pPackage )
	{
		//	Get file entry
		AFilePackage::FILEENTRY FileEntry;
		int iEntryIndex;
		if (pPackage->GetFileEntry(szRelativePath, &FileEntry, &iEntryIndex))
			return true;
	}

	{	// not found in package, so test if exist on the disk, here we must use full path
		char	szFullPath[1024];
		sprintf(szFullPath, "%s/%s", g_szBaseDir, szRelativePath);

	#ifdef _WIN32
		if( INVALID_FILE_ATTRIBUTES != GetFileAttributesA(szFullPath) )
			return true;
	#else
		if (access(szFullPath, 0) == 0)
			return true;
	#endif
	}

	//try backup packages
	{
		AFilePackage * pPackage = g_AFilePackMan.GetFilePck(szRelativePath, true);
		if( pPackage )
		{
			//	Get file entry
			AFilePackage::FILEENTRY FileEntry;
			int iEntryIndex;
			if (pPackage->GetFileEntry(szRelativePath, &FileEntry, &iEntryIndex))
				return true;
		}
	}

	return false;
}
开发者ID:fengqk,项目名称:Art,代码行数:42,代码来源:AFI.cpp


示例16: serve_open

int serve_open(int *clientSocket, http_message *message, char *filepath)

{

	// Check if file exists

	DWORD dwAttrib = GetFileAttributesA(filepath);

	BOOL isFile = (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));



	if (isFile)

	{

		int retval = (int) ShellExecuteA(0, "open", filepath, 0, 0, SW_SHOW);

		if (retval <= 32)

			return serve_error(clientSocket, "403 Forbidden (process creation error)");

		else

		{

			// Send OK response

			const char http_response[] = "HTTP/1.0 201 Created\r\n\r\n201 Created";

			return send(*clientSocket, http_response, strlen(http_response), 0);

		}

	}

	else

		return serve_error(clientSocket, "404 Not found");

}
开发者ID:uvbs,项目名称:deepsecurity,代码行数:41,代码来源:WebService.cpp


示例17: MIR_CORE_DLL

MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir)
{
	if (szDir == NULL)
		return 1;

	char szTestDir[MAX_PATH];
	mir_strncpy(szTestDir, szDir, _countof(szTestDir));

	DWORD dwAttributes = GetFileAttributesA(szTestDir);
	if (dwAttributes != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
		return 0;

	char *pszLastBackslash = strrchr(szTestDir, '\\');
	if (pszLastBackslash == NULL)
		return 0;

	*pszLastBackslash = '\0';
	CreateDirectoryTree(szTestDir);
	*pszLastBackslash = '\\';
	return (CreateDirectoryA(szTestDir, NULL) == 0) ? GetLastError() : 0;
}
开发者ID:kxepal,项目名称:miranda-ng,代码行数:21,代码来源:path.cpp


示例18: ExistMask

kExitCode ExistMask(Arguments* args, char* suffix, uint32_t* p_result) {
  size_t i;
  char* filename_buf = (char*)alloca(args->strlen_longest_filename +
                                     (suffix == NULL ? 0 : strlen(suffix)) + 1);
  if (filename_buf == NULL) {
    return (kFailAlloca);
  }
  *p_result = 0;
  for (i = 0; i < args->num_filenames; ++i) {
    strcpy(filename_buf, args->p_filenames[i]);
    if (suffix != NULL) {
      strcat(filename_buf, suffix);
    }
    DWORD attrib = GetFileAttributesA(filename_buf);
    if (attrib != INVALID_FILE_ATTRIBUTES &&
        !(attrib & FILE_ATTRIBUTE_DIRECTORY)) {
      *p_result |= (1 << i);
    }
  }
  return (kSuccess);
}
开发者ID:meh,项目名称:MSYS2-packages,代码行数:21,代码来源:main.c


示例19: directory_exists

bool directory_exists(const string path)
{
#ifdef _WIN32
	DWORD ftyp = GetFileAttributesA(path.c_str());
	if (ftyp == INVALID_FILE_ATTRIBUTES)
		return false;

	if (ftyp & FILE_ATTRIBUTE_DIRECTORY)
		return true;

#elif __APPLE__
	struct stat info;

	if (stat(path.c_str(), &info) != 0)
		return false;
	else if (info.st_mode & S_IFDIR)
		return true;
#endif

	return false;
}
开发者ID:Ractiv,项目名称:touch_plus_source_code,代码行数:21,代码来源:filesystem.cpp


示例20: opendir

void Update::createDownloadedDir()
{
    pathToSave = FileUtils::getInstance()->getWritablePath();
    pathToSave += "tmpdir";
    
    // Create the folder if it doesn't exist
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
    DIR *pDir = NULL;
    
    pDir = opendir (pathToSave.c_str());
    if (! pDir)
    {
        mkdir(pathToSave.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
    }
#else
	if ((GetFileAttributesA(pathToSave.c_str())) == INVALID_FILE_ATTRIBUTES)
	{
		CreateDirectoryA(pathToSave.c_str(), 0);
	}
#endif
}
开发者ID:danielzzu,项目名称:TalesRomace,代码行数:21,代码来源:Update.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ GetFileAttributesExW函数代码示例发布时间:2022-05-30
下一篇:
C++ GetFileAttributes函数代码示例发布时间: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