本文整理汇总了C++中GetFileAttributesExW函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFileAttributesExW函数的具体用法?C++ GetFileAttributesExW怎么用?C++ GetFileAttributesExW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFileAttributesExW函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: hooked_stat
//------------------------------------------------------------------------------
int hooked_stat(const char* path, struct hooked_stat* out)
{
int ret = -1;
WIN32_FILE_ATTRIBUTE_DATA fad;
wchar_t buf[2048];
size_t characters;
// Utf8 to wchars.
characters = MultiByteToWideChar(
CP_UTF8, 0,
path, -1,
buf, sizeof_array(buf)
);
characters = characters ? characters : sizeof_array(buf) - 1;
buf[characters] = L'\0';
// Get properties.
out->st_size = 0;
out->st_mode = 0;
if (GetFileAttributesExW(buf, GetFileExInfoStandard, &fad) != 0)
{
unsigned dir_bit;
dir_bit = (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : 0;
out->st_size = fad.nFileSizeLow;
out->st_mode |= dir_bit;
ret = 0;
}
else
errno = ENOENT;
return ret;
}
开发者ID:EdSchroedinger,项目名称:clink,代码行数:36,代码来源:hooks.c
示例2: omrfile_length
int64_t
omrfile_length(struct OMRPortLibrary *portLibrary, const char *path)
{
int64_t result = -1;
wchar_t unicodeBuffer[UNICODE_BUFFER_SIZE], *unicodePath;
Trc_PRT_file_length_Entry(path);
/* Convert the filename from UTF8 to Unicode */
unicodePath = file_get_unicode_path(portLibrary, path, unicodeBuffer, UNICODE_BUFFER_SIZE);
if (NULL != unicodePath) {
WIN32_FILE_ATTRIBUTE_DATA myStat;
if (0 == GetFileAttributesExW(unicodePath, GetFileExInfoStandard, &myStat)) {
int32_t error = GetLastError();
result = portLibrary->error_set_last_error(portLibrary, error, findError(error));
} else {
result = ((int64_t)myStat.nFileSizeHigh) << 32;
result += (int64_t)myStat.nFileSizeLow;
}
if (unicodeBuffer != unicodePath) {
portLibrary->mem_free_memory(portLibrary, unicodePath);
}
}
Trc_PRT_file_length_Exit(result);
return result;
}
开发者ID:dinogun,项目名称:omr,代码行数:28,代码来源:omrfile.c
示例3: FileMonikerImpl_GetTimeOfLastChange
/******************************************************************************
* FileMoniker_GetTimeOfLastChange
******************************************************************************/
static HRESULT WINAPI
FileMonikerImpl_GetTimeOfLastChange(IMoniker* iface, IBindCtx* pbc,
IMoniker* pmkToLeft, FILETIME* pFileTime)
{
FileMonikerImpl *This = impl_from_IMoniker(iface);
IRunningObjectTable* rot;
HRESULT res;
WIN32_FILE_ATTRIBUTE_DATA info;
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pFileTime);
if (pFileTime==NULL)
return E_POINTER;
if (pmkToLeft!=NULL)
return E_INVALIDARG;
res=IBindCtx_GetRunningObjectTable(pbc,&rot);
if (FAILED(res))
return res;
res= IRunningObjectTable_GetTimeOfLastChange(rot,iface,pFileTime);
if (FAILED(res)){ /* the moniker is not registered */
if (!GetFileAttributesExW(This->filePathName,GetFileExInfoStandard,&info))
return MK_E_NOOBJECT;
*pFileTime=info.ftLastWriteTime;
}
return S_OK;
}
开发者ID:Barrell,项目名称:wine,代码行数:37,代码来源:filemoniker.c
示例4: stat
bool fs::stat(const std::string& path, stat_t& info)
{
g_tls_error = fse::ok;
#ifdef _WIN32
WIN32_FILE_ATTRIBUTE_DATA attrs;
if (!GetFileAttributesExW(to_wchar(path).get(), GetFileExInfoStandard, &attrs))
{
return false;
}
info.is_directory = (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
info.is_writable = (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
info.size = (u64)attrs.nFileSizeLow | ((u64)attrs.nFileSizeHigh << 32);
info.atime = to_time_t(attrs.ftLastAccessTime);
info.mtime = to_time_t(attrs.ftLastWriteTime);
info.ctime = to_time_t(attrs.ftCreationTime);
#else
struct stat file_info;
if (stat(path.c_str(), &file_info) < 0)
{
return false;
}
info.is_directory = S_ISDIR(file_info.st_mode);
info.is_writable = file_info.st_mode & 0200; // HACK: approximation
info.size = file_info.st_size;
info.atime = file_info.st_atime;
info.mtime = file_info.st_mtime;
info.ctime = file_info.st_ctime;
#endif
return true;
}
开发者ID:rodrigonh,项目名称:rpcs3,代码行数:34,代码来源:File.cpp
示例5: _wchmod
// Changes the mode of a file. The only supported mode bit is _S_IWRITE, which
// controls the user write (read-only) attribute of the file. Returns zero if
// successful; returns -1 and sets errno and _doserrno on failure.
extern "C" int __cdecl _wchmod(wchar_t const* const path, int const mode)
{
_VALIDATE_CLEAR_OSSERR_RETURN(path != nullptr, EINVAL, -1);
WIN32_FILE_ATTRIBUTE_DATA attributes;
if (!GetFileAttributesExW(path, GetFileExInfoStandard, &attributes))
{
__acrt_errno_map_os_error(GetLastError());
return -1;
}
// Set or clear the read-only flag:
if (mode & _S_IWRITE)
{
attributes.dwFileAttributes &= ~FILE_ATTRIBUTE_READONLY;
}
else
{
attributes.dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
}
if (!SetFileAttributesW(path, attributes.dwFileAttributes))
{
__acrt_errno_map_os_error(GetLastError());
return -1;
}
return 0;
}
开发者ID:DinrusGroup,项目名称:DinrusUcrtBased,代码行数:32,代码来源:wchmod.cpp
示例6: Java_net_rubygrapefruit_platform_internal_jni_WindowsFileFunctions_stat
JNIEXPORT void JNICALL
Java_net_rubygrapefruit_platform_internal_jni_WindowsFileFunctions_stat(JNIEnv *env, jclass target, jstring path, jobject dest, jobject result) {
jclass destClass = env->GetObjectClass(dest);
jmethodID mid = env->GetMethodID(destClass, "details", "(IJJ)V");
if (mid == NULL) {
mark_failed_with_message(env, "could not find method", result);
return;
}
WIN32_FILE_ATTRIBUTE_DATA attr;
wchar_t* pathStr = java_to_wchar(env, path, result);
BOOL ok = GetFileAttributesExW(pathStr, GetFileExInfoStandard, &attr);
free(pathStr);
if (!ok) {
DWORD error = GetLastError();
if (error == ERROR_FILE_NOT_FOUND || error == ERROR_PATH_NOT_FOUND || error == ERROR_NOT_READY) {
// Treat device with no media as missing
env->CallVoidMethod(dest, mid, (jint)FILE_TYPE_MISSING, (jlong)0, (jlong)0);
return;
}
mark_failed_with_errno(env, "could not file attributes", result);
return;
}
jlong lastModified = lastModifiedNanos(&attr.ftLastWriteTime);
if (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
env->CallVoidMethod(dest, mid, (jint)FILE_TYPE_DIRECTORY, (jlong)0, lastModified);
} else {
jlong size = ((jlong)attr.nFileSizeHigh << 32) | attr.nFileSizeLow;
env->CallVoidMethod(dest, mid, (jint)FILE_TYPE_FILE, size, lastModified);
}
}
开发者ID:adammurdoch,项目名称:native-platform,代码行数:31,代码来源:win.cpp
示例7: win32_wstat
/*
* The CRT of Windows has a number of flaws wrt. its stat() implementation:
* - time stamps are restricted to second resolution
* - file modification times suffer from forth-and-back conversions between
* UTC and local time
* Therefore, we implement our own stat, based on the Win32 API directly.
*
* This is based on the Python 2 implementation from:
* https://github.com/python/cpython/commit/14694662d530d0d1823e1d86f2e5b2e4ec600e86#diff-a6f29e907cbb5fffd44d453bcd7b77d5R741
*/
static int
win32_wstat(const wchar_t* path, struct meterp_stat *result)
{
int code;
const wchar_t *dot;
WIN32_FILE_ATTRIBUTE_DATA info;
if (!GetFileAttributesExW(path, GetFileExInfoStandard, &info)) {
if (GetLastError() != ERROR_SHARING_VIOLATION) {
return -1;
}
else {
if (!attributes_from_dir_w(path, &info)) {
return -1;
}
}
}
code = attribute_data_to_stat(&info, result);
if (code < 0) {
return code;
}
/* Set IFEXEC if it is an .exe, .bat, ... */
dot = wcsrchr(path, '.');
if (dot) {
if (_wcsicmp(dot, L".bat") == 0 ||
_wcsicmp(dot, L".cmd") == 0 ||
_wcsicmp(dot, L".exe") == 0 ||
_wcsicmp(dot, L".com") == 0)
result->st_mode |= 0111;
}
return code;
}
开发者ID:AnwarMohamed,项目名称:metasploit-payloads,代码行数:41,代码来源:fs_win.c
示例8: omrfile_lastmod
int64_t
omrfile_lastmod(struct OMRPortLibrary *portLibrary, const char *path)
{
int64_t result = -1;
wchar_t unicodeBuffer[UNICODE_BUFFER_SIZE], *unicodePath;
Trc_PRT_file_lastmod_Entry(path);
/* Convert the filename from UTF8 to Unicode */
unicodePath = file_get_unicode_path(portLibrary, path, unicodeBuffer, UNICODE_BUFFER_SIZE);
if (NULL != unicodePath) {
WIN32_FILE_ATTRIBUTE_DATA myStat;
if (0 == GetFileAttributesExW(unicodePath, GetFileExInfoStandard, &myStat)) {
int32_t error = GetLastError();
result = portLibrary->error_set_last_error(portLibrary, error, findError(error));
} else {
/*
* Search MSDN for 'Converting a time_t Value to a File Time' for following implementation.
*/
result = ((int64_t) myStat.ftLastWriteTime.dwHighDateTime << 32) | (int64_t) myStat.ftLastWriteTime.dwLowDateTime;
result = (result - 116444736000000000) / 10000;
}
if (unicodeBuffer != unicodePath) {
portLibrary->mem_free_memory(portLibrary, unicodePath);
}
}
Trc_PRT_file_lastmod_Exit(result);
return result;
}
开发者ID:dinogun,项目名称:omr,代码行数:31,代码来源:omrfile.c
示例9: _EbrIsDir
static bool _EbrIsDir(const wchar_t* path) {
WIN32_FILE_ATTRIBUTE_DATA fileAttribData;
if (GetFileAttributesExW(path, GetFileExInfoStandard, &fileAttribData)) {
if ((fileAttribData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
return true;
}
return false;
}
开发者ID:RG-J,项目名称:WinObjC,代码行数:8,代码来源:AssetFile.cpp
示例10: tr_sys_path_get_info
bool tr_sys_path_get_info(char const* path, int flags, tr_sys_path_info* info, tr_error** error)
{
TR_ASSERT(path != NULL);
TR_ASSERT(info != NULL);
bool ret = false;
wchar_t* wide_path = path_to_native_path(path);
if ((flags & TR_SYS_PATH_NO_FOLLOW) == 0)
{
HANDLE handle = INVALID_HANDLE_VALUE;
if (wide_path != NULL)
{
handle = CreateFileW(wide_path, 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
}
if (handle != INVALID_HANDLE_VALUE)
{
tr_error* my_error = NULL;
ret = tr_sys_file_get_info(handle, info, &my_error);
if (!ret)
{
tr_error_propagate(error, &my_error);
}
CloseHandle(handle);
}
else
{
set_system_error(error, GetLastError());
}
}
else
{
WIN32_FILE_ATTRIBUTE_DATA attributes;
if (wide_path != NULL)
{
ret = GetFileAttributesExW(wide_path, GetFileExInfoStandard, &attributes);
}
if (ret)
{
stat_to_sys_path_info(attributes.dwFileAttributes, attributes.nFileSizeLow, attributes.nFileSizeHigh,
&attributes.ftLastWriteTime, info);
}
else
{
set_system_error(error, GetLastError());
}
}
tr_free(wide_path);
return ret;
}
开发者ID:xzcvczx,项目名称:transmission,代码行数:58,代码来源:file-win32.c
示例11: doPlatformExists
static int doPlatformExists(LPWSTR wpath)
{
WIN32_FILE_ATTRIBUTE_DATA a;
// Returns non-zero if successful
BOOL retval = GetFileAttributesExW(wpath, GetFileExInfoStandard, &a);
return(retval);
} /* doPlatformExists */
开发者ID:ahrnbom,项目名称:physfs-uwp,代码行数:9,代码来源:winrt.cpp
示例12: CHECK_WIN32_BOOL
long DVLib::GetFileSize(const std::wstring& filename)
{
WIN32_FILE_ATTRIBUTE_DATA attr = { 0 };
CHECK_WIN32_BOOL(GetFileAttributesExW(filename.c_str(), GetFileExInfoStandard, & attr),
L"Error getting file attributes of " << filename);
CHECK_BOOL(0 == attr.nFileSizeHigh,
L"File " << filename << L" is > 2GB (" << attr.nFileSizeHigh << ")");
return (long) attr.nFileSizeLow;
}
开发者ID:AllanDragoon,项目名称:dotnetinstaller,代码行数:9,代码来源:FileUtil.cpp
示例13: GetFileAttributesW
DWORD WINAPI_DECL GetFileAttributesW(
_In_ LPCWSTR lpFileName
)
{
WIN32_FILE_ATTRIBUTE_DATA fileInformation;
BOOL b = GetFileAttributesExW(
lpFileName,
GetFileExInfoStandard,
&fileInformation);
return b ? fileInformation.dwFileAttributes : INVALID_FILE_ATTRIBUTES;
}
开发者ID:huangyt,项目名称:MyProjects,代码行数:11,代码来源:FileSystemEmulation.cpp
示例14: GetFileAttributesExW
void WinNode::stat_impl(NodeStat& dst)
{
WIN32_FILE_ATTRIBUTE_DATA attrs = { 0 };
GetFileAttributesExW(m_nativePath.c_str(), GetFileExInfoStandard, &attrs);
filetimeToUint64(dst.ctime, attrs.ftCreationTime);
filetimeToUint64(dst.mtime, attrs.ftLastWriteTime);
filetimeToUint64(dst.atime, attrs.ftLastAccessTime);
dst.id = m_id;
dst.size = ((uint64)attrs.nFileSizeHigh << 32) | attrs.nFileSizeLow;
}
开发者ID:kona4kona,项目名称:HiME_,代码行数:12,代码来源:hime-fs-winfs.cpp
示例15: memset
ticks_t Platform::getFileModificationTime(std::string file)
{
boost::replace_all(file, "/", "\\");
std::wstring wfile = stdext::utf8_to_utf16(file);
WIN32_FILE_ATTRIBUTE_DATA fileAttrData;
memset(&fileAttrData, 0, sizeof(fileAttrData));
GetFileAttributesExW(wfile.c_str(), GetFileExInfoStandard, &fileAttrData);
ULARGE_INTEGER uli;
uli.LowPart = fileAttrData.ftLastWriteTime.dwLowDateTime;
uli.HighPart = fileAttrData.ftLastWriteTime.dwHighDateTime;
return uli.QuadPart;
}
开发者ID:Ablankzin,项目名称:otclient,代码行数:12,代码来源:win32platform.cpp
示例16: RtlZeroMemory
HRESULT CFileWatcher::GetWatchedFileTimestamp(WatchedFile* file, FILETIME* timestamp)
{
HRESULT hr;
WIN32_FILE_ATTRIBUTE_DATA attributes;
WIN32_FIND_DATAW findData;
HANDLE foundFile = INVALID_HANDLE_VALUE;
if (file->wildcard)
{
// a timestamp of a wildcard watched file is the XOR of the timestamps of all matching files and their names and sizes;
// that way if any of the matching files changes, or matching files are added or removed, the timestamp will change as well
RtlZeroMemory(timestamp, sizeof FILETIME);
foundFile = FindFirstFileW(file->fileName, &findData);
if (INVALID_HANDLE_VALUE != foundFile)
{
do
{
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
timestamp->dwHighDateTime ^= findData.ftLastWriteTime.dwHighDateTime ^ findData.nFileSizeHigh;
timestamp->dwLowDateTime ^= findData.ftLastWriteTime.dwLowDateTime ^ findData.nFileSizeLow;
WCHAR* current = findData.cFileName;
while (*current)
{
timestamp->dwLowDateTime ^= *current;
current++;
}
}
} while (FindNextFileW(foundFile, &findData));
ErrorIf(ERROR_NO_MORE_FILES != (hr = GetLastError()), hr);
FindClose(foundFile);
foundFile = NULL;
}
}
else
{
ErrorIf(!GetFileAttributesExW(file->fileName, GetFileExInfoStandard, &attributes), GetLastError());
memcpy(timestamp, &attributes.ftLastWriteTime, sizeof attributes.ftLastWriteTime);
}
return S_OK;
Error:
if (INVALID_HANDLE_VALUE != foundFile)
{
FindClose(foundFile);
foundFile = INVALID_HANDLE_VALUE;
}
return hr;
}
开发者ID:Cahya,项目名称:iisnode,代码行数:53,代码来源:cfilewatcher.cpp
示例17: sys_file_type
/**
sys_file_type : string -> string
<doc>
Return the type of the file. The current values are possible :
<ul>
<li>[file]</li>
<li>[dir]</li>
<li>[symlink]</li>
<li>[sock]</li>
<li>[char]</li>
<li>[block]</li>
<li>[fifo]</li>
</ul>
</doc>
**/
static value sys_file_type( value path ) {
#if defined(EPPC) || defined(KORE_CONSOLE)
return alloc_null();
#else
val_check(path,string);
#ifdef NEKO_WINDOWS
const wchar_t* _path = val_wstring(path);
gc_enter_blocking();
WIN32_FILE_ATTRIBUTE_DATA data;
if( !GetFileAttributesExW(_path,GetFileExInfoStandard,&data) )
{
gc_exit_blocking();
return alloc_null();
}
gc_exit_blocking();
if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
return alloc_string("dir");
}
else
{
return alloc_string("file");
}
#else
struct stat s;
gc_enter_blocking();
if( stat(val_string(path),&s) != 0 )
{
gc_exit_blocking();
return alloc_null();
}
gc_exit_blocking();
if( s.st_mode & S_IFREG )
return alloc_string("file");
if( s.st_mode & S_IFDIR )
return alloc_string("dir");
if( s.st_mode & S_IFCHR )
return alloc_string("char");
#ifndef NEKO_WINDOWS
if( s.st_mode & S_IFLNK )
return alloc_string("symlink");
if( s.st_mode & S_IFBLK )
return alloc_string("block");
if( s.st_mode & S_IFIFO )
return alloc_string("fifo");
if( s.st_mode & S_IFSOCK )
return alloc_string("sock");
#endif
#endif
return alloc_null();
#endif
}
开发者ID:KTXSoftware,项目名称:khacpp,代码行数:67,代码来源:Sys.winrt.cpp
示例18: is_file_existsW
bool is_file_existsW(_In_ const wchar_t* file_path)
{
_ASSERTE(NULL != file_path);
_ASSERTE(TRUE != IsBadStringPtrW(file_path, MAX_PATH));
if ((NULL == file_path) || (TRUE == IsBadStringPtrW(file_path, MAX_PATH))) return false;
WIN32_FILE_ATTRIBUTE_DATA info = { 0 };
if (GetFileAttributesExW(file_path, GetFileExInfoStandard, &info) == 0)
return false;
else
return true;
}
开发者ID:tkaqls,项目名称:bob4,代码行数:13,代码来源:test3.cpp
示例19: getFileAttributes
bool getFileAttributes(const char* path, uint64_t* mtime, uint64_t* size)
{
WIN32_FILE_ATTRIBUTE_DATA data;
if (GetFileAttributesExW(fromUtf8(path).c_str(), GetFileExInfoStandard, &data))
{
*mtime = combine(data.ftLastWriteTime.dwHighDateTime, data.ftLastWriteTime.dwLowDateTime);
*size = combine(data.nFileSizeHigh, data.nFileSizeLow);
return true;
}
return false;
}
开发者ID:zeux,项目名称:qgrep,代码行数:13,代码来源:fileutil_win.cpp
示例20: TypeOf
Yuni::IO::NodeType TypeOf(const AnyString& filename)
{
if (filename.empty())
return Yuni::IO::typeUnknown;
# ifdef YUNI_OS_WINDOWS
const char* p = filename.c_str();
unsigned int len = filename.size();
if (p[len - 1] == '\\' or p[len - 1] == '/')
{
if (!--len)
{
# ifdef YUNI_OS_WINDOWS
return Yuni::IO::typeUnknown;
# else
// On Unixes, `/` is a valid folder
return Yuni::IO::typeFolder;
# endif
}
}
// Driver letters
if (len == 2 and p[1] == ':')
return Yuni::IO::typeFolder;
String norm;
Yuni::IO::Normalize(norm, AnyString(p, len));
// Conversion into wchar_t
Private::WString<true> wstr(norm);
if (wstr.empty())
return Yuni::IO::typeUnknown;
WIN32_FILE_ATTRIBUTE_DATA infoFile;
if (!GetFileAttributesExW(wstr.c_str(), GetFileExInfoStandard, &infoFile))
return Yuni::IO::typeUnknown;
return ((infoFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
? Yuni::IO::typeFolder
: Yuni::IO::typeFile;
# else // WINDOWS
struct stat s;
if (stat(filename.c_str(), &s) != 0)
return Yuni::IO::typeUnknown;
return (S_ISDIR(s.st_mode))
? Yuni::IO::typeFolder
: Yuni::IO::typeFile;
# endif
}
开发者ID:MAPJe71,项目名称:libyuni,代码行数:51,代码来源:exists.cpp
注:本文中的GetFileAttributesExW函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论