本文整理汇总了C++中GetFullPathNameW函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFullPathNameW函数的具体用法?C++ GetFullPathNameW怎么用?C++ GetFullPathNameW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFullPathNameW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Normalize
plFileName plFileName::AbsolutePath() const
{
if (!IsValid())
return *this;
plFileName path = Normalize();
#if HS_BUILD_FOR_WIN32
plStringBuffer<wchar_t> wideName = path.fName.ToWchar();
wchar_t path_sm[MAX_PATH];
uint32_t path_length = GetFullPathNameW(wideName, MAX_PATH, path_sm, nullptr);
if (path_length >= MAX_PATH) {
// Buffer not big enough
wchar_t *path_lg = new wchar_t[path_length];
GetFullPathNameW(wideName, path_length, path_lg, nullptr);
path = plString::FromWchar(path_lg);
delete [] path_lg;
} else {
path = plString::FromWchar(path_sm);
}
#else
char *path_a = realpath(path.fName.c_str(), nullptr);
hsAssert(path_a, "Failure to get absolute path (unsupported libc?)");
path = path_a;
free(path_a);
#endif
return path;
}
示例2: g_malloc
static struct filename_representations
*filename_representations_new(const char *raw, int type)
{
struct filename_representations *fr;
char *display_pre;
char *real_path;
#ifdef G_OS_WIN32
DWORD buffer_length;
gunichar2 *raw_utf16, *real_path_utf16;
#endif
fr = g_malloc(sizeof(struct filename_representations));
fr->type = type;
fr->raw = g_strdup(raw);
#ifdef G_OS_WIN32
raw_utf16 = g_utf8_to_utf16(fr->raw, -1, NULL, NULL, NULL);
buffer_length = GetFullPathNameW(raw_utf16, 0, NULL, NULL);
real_path_utf16 = g_malloc(buffer_length * sizeof(gunichar2));
GetFullPathNameW(raw_utf16, buffer_length, real_path_utf16, NULL);
real_path = g_utf16_to_utf8(raw_utf16, -1, NULL, NULL, NULL);
g_free(real_path_utf16);
g_free(raw_utf16);
#else
real_path = realpath(fr->raw, NULL);
#endif
display_pre = g_filename_display_name(real_path);
fr->collate_key = g_utf8_collate_key_for_filename(display_pre, -1);
fr->display = g_strescape(display_pre,
(const gchar *) strescape_exceptions);
g_free(display_pre);
g_free(real_path);
return fr;
}
示例3: PutFilePathName1017
bool PutFilePathName1017(UnicodeFileName* aFullName, const wchar_t* pFileName)
{
wchar_t* pFullName = aFullName->GetBuffer(MAX_PIC_PATH_LEN);
wchar_t sFullName[MAX_PATH*2], *pszPart=NULL;
DWORD nCount = sizeof(sFullName)/sizeof(sFullName[0]);
bool result = false;
DWORD nLen = GetFullPathNameW(pFileName, nCount, sFullName, &pszPart);
if (!nLen)
return false; // не смогли?
if (nLen > nCount) {
wchar_t* pszBuffer = (wchar_t*)malloc(nLen * sizeof(wchar_t));
_ASSERTE(pszBuffer);
nLen = GetFullPathNameW(pFileName, nLen, pszBuffer, &pszPart);
if (nLen) {
aFullName->Assign(pszBuffer);
result = true;
}
free(pszBuffer);
} else {
aFullName->Assign(sFullName);
result = true;
}
return result;
}
示例4: get_full_path_name
wstring get_full_path_name(const wstring& path) {
Buffer<wchar_t> buf(MAX_PATH);
DWORD size = GetFullPathNameW(path.c_str(), static_cast<DWORD>(buf.size()), buf.data(), nullptr);
if (size > buf.size()) {
buf.resize(size);
size = GetFullPathNameW(path.c_str(), static_cast<DWORD>(buf.size()), buf.data(), nullptr);
}
CHECK_SYS(size);
return wstring(buf.data(), size);
}
示例5: make_absolute_and_transform_to_utf8_and_make_vpath
static
rc_t make_absolute_and_transform_to_utf8_and_make_vpath ( const VFSManager * self,
VPath ** new_path, const wchar_t * src, bool have_drive )
{
rc_t rc;
wchar_t full [ 4096 ];
/* expand to full path - this is temporary, and will be replaced after KFS is updated */
DWORD len = GetFullPathNameW ( src, sizeof full / sizeof full [ 0 ], full, NULL );
if ( len == 0 )
{
/* we have an error */
DWORD status = GetLastError ();
DBGMSG ( DBG_VFS, DBG_FLAG_ANY, ( "GetFullPathNameW: error code - %u.\n", status ) );
rc = RC ( rcVFS, rcMgr, rcConstructing, rcPath, rcInvalid );
}
else if ( len >= sizeof full / sizeof full [ 0 ] )
{
/* the buffer is too small ! */
wchar_t * big_buf = malloc( ( ++len ) * ( sizeof full[ 0 ] ) );
if ( big_buf == NULL )
rc = RC ( rcVFS, rcMgr, rcConstructing, rcMemory, rcExhausted );
else
{
DWORD len2 = GetFullPathNameW ( src, len, big_buf, NULL );
if ( len2 == 0 )
{
/* we have an error */
DWORD status = GetLastError ();
DBGMSG ( DBG_VFS, DBG_FLAG_ANY, ( "GetFullPathNameW: error code - %u.\n", status ) );
rc = RC ( rcVFS, rcMgr, rcConstructing, rcPath, rcInvalid );
}
else if ( len2 >= len )
{
DBGMSG ( DBG_VFS, DBG_FLAG_ANY, ( "GetFullPathNameW: buffer too small again - %u.\n", len2 ) );
rc = RC ( rcVFS, rcMgr, rcConstructing, rcPath, rcInvalid );
}
else
{
/* now we can call the final transform and make */
rc = transform_to_utf8_and_make_vpath( self, new_path, big_buf, true );
}
free( big_buf );
}
}
else
{
/* now we can call the final transform and make */
rc = transform_to_utf8_and_make_vpath( self, new_path, full, true );
}
return rc;
}
示例6: RTDECL
/**
* Get the real (no symlinks, no . or .. components) path, must exist.
*
* @returns iprt status code.
* @param pszPath The path to resolve.
* @param pszRealPath Where to store the real path.
* @param cchRealPath Size of the buffer.
*/
RTDECL(int) RTPathReal(const char *pszPath, char *pszRealPath, size_t cchRealPath)
{
/*
* Convert to UTF-16, call Win32 APIs, convert back.
*/
PRTUTF16 pwszPath;
int rc = RTStrToUtf16(pszPath, &pwszPath);
if (!RT_SUCCESS(rc))
return (rc);
LPWSTR lpFile;
WCHAR wsz[RTPATH_MAX];
rc = GetFullPathNameW((LPCWSTR)pwszPath, RT_ELEMENTS(wsz), &wsz[0], &lpFile);
if (rc > 0 && rc < RT_ELEMENTS(wsz))
{
/* Check that it exists. (Use RTPathAbs() to just resolve the name.) */
DWORD dwAttr = GetFileAttributesW(wsz);
if (dwAttr != INVALID_FILE_ATTRIBUTES)
rc = RTUtf16ToUtf8Ex((PRTUTF16)&wsz[0], RTSTR_MAX, &pszRealPath, cchRealPath, NULL);
else
rc = RTErrConvertFromWin32(GetLastError());
}
else if (rc <= 0)
rc = RTErrConvertFromWin32(GetLastError());
else
rc = VERR_FILENAME_TOO_LONG;
RTUtf16Free(pwszPath);
return rc;
}
示例7: absolute_path
static std::string absolute_path(const std::string &path) {
std::wstring wpath = transcode_utf8_to_utf16(path);
wchar_t buf[MAX_PATH+1];
DWORD len = GetFullPathNameW(wpath.c_str(), MAX_PATH, buf, 0);
buf[len] = L'\0';
return transcode_utf16_to_utf8(buf, len);
}
示例8: ConvertToNtPath
bool ConvertToNtPath(const wchar_t* path, wchar_t* normalized, size_t normalizedLen)
{
UNICODE_STRING ntPath;
DWORD size;
bool result = false;
size = GetFullPathNameW(path, (DWORD)normalizedLen, normalized, NULL);
if (size == 0)
return false;
memset(&ntPath, 0, sizeof(ntPath));
if (RtlDosPathNameToRelativeNtPathName_U(normalized, &ntPath, NULL, NULL) == FALSE)
return false;
if (normalizedLen * sizeof(wchar_t) > ntPath.Length)
{
memcpy(normalized, ntPath.Buffer, ntPath.Length);
normalized[ntPath.Length / sizeof(wchar_t)] = L'\0';
result = true;
}
HeapFree(GetProcessHeap(), 0, ntPath.Buffer);
return result;
}
示例9: cmdLogFile
void cmdLogFile(int argc, wchar_t** argv)
{
TurnOffLogFile();
const wchar_t* fileName = L"HeapMonitorTrace.log";
if (argc >= 1)
{
// turn off
if (_wcsicmp(argv[0], L"off") == 0)
{
wprintf(L"LogFile is turned off\n");
return;
}
else
{
fileName = argv[0];
}
}
g_logFile = CreateFileW(fileName, GENERIC_WRITE, FILE_SHARE_READ, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (g_logFile == INVALID_HANDLE_VALUE) {
wprintf(L"Cannot open LogFile %ls\n", fileName);
return;
}
SetFilePointer(g_logFile, 0, NULL, FILE_END);
wchar_t fullName[MAX_PATH] = { 0 };
wchar_t *pszFilePart = NULL;
GetFullPathNameW(fileName, MAX_PATH, fullName, &pszFilePart);
wprintf(L"LogFile is turned on, File=%ls\n", fullName);
}
示例10: GetFullPathNameW
bool FolderBrowserDialog::SetBufFromDir(const wchar_t * src, wchar_t* buf, int blen)
{
DWORD retlen = GetFullPathNameW(src, blen, buf, NULL);
if (retlen && retlen < MAX_WPATH && PathIsDirectoryW(buf))
return true;
return false;
}
示例11: stat_dev_for
static dev_t stat_dev_for(const wchar_t *wpathname)
{
DWORD len;
wchar_t *fullpath;
len = GetFullPathNameW(wpathname, 0, NULL, NULL);
fullpath = __builtin_alloca((len + 1) * sizeof(wchar_t));
if(!GetFullPathNameW(wpathname, len, fullpath, NULL)) {
fprintf(stderr, "tup error: GetFullPathNameW(\"%ls\") failed: 0x%08lx\n", wpathname, GetLastError());
return 0;
}
if(fullpath[1] != L':') {
return 0;
}
return fullpath[0] - L'A';
}
示例12: utf8to16String
result_t path_base::fullpath(exlib::string path, exlib::string &retVal)
{
#ifdef _WIN32
exlib::wstring str = utf8to16String(path);
exlib::wchar utf16_buffer[MAX_PATH];
DWORD utf16_len = GetFullPathNameW(str.c_str(), MAX_PATH, utf16_buffer, NULL);
if (!utf16_len)
return CHECK_ERROR(LastError());
retVal = utf16to8String(utf16_buffer, (int32_t)utf16_len);
return 0;
#else
if (isPathSlash(path.c_str()[0]))
return normalize(path, retVal);
exlib::string str;
process_base::cwd(str);
str.append(1, PATH_SLASH);
str.append(path);
return normalize(str, retVal);
#endif
}
示例13: SIC_GetIconIndex
/*****************************************************************************
* SIC_GetIconIndex [internal]
*
* Parameters
* sSourceFile [IN] filename of file containing the icon
* index [IN] index/resID (negated) in this file
*
* NOTES
* look in the cache for a proper icon. if not available the icon is taken
* from the file and cached
*/
INT SIC_GetIconIndex (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags )
{
SIC_ENTRY sice;
INT ret, index = INVALID_INDEX;
WCHAR path[MAX_PATH];
TRACE("%s %i\n", debugstr_w(sSourceFile), dwSourceIndex);
GetFullPathNameW(sSourceFile, MAX_PATH, path, NULL);
sice.sSourceFile = path;
sice.dwSourceIndex = dwSourceIndex;
sice.dwFlags = dwFlags;
EnterCriticalSection(&SHELL32_SicCS);
if (NULL != DPA_GetPtr (sic_hdpa, 0))
{
/* search linear from position 0*/
index = DPA_Search (sic_hdpa, &sice, 0, SIC_CompareEntries, 0, DPAS_SORTED);
}
if ( INVALID_INDEX == index )
{
ret = SIC_LoadIcon (sSourceFile, dwSourceIndex, dwFlags);
}
else
{
TRACE("-- found\n");
ret = ((LPSIC_ENTRY)DPA_GetPtr(sic_hdpa, index))->dwListIndex;
}
LeaveCriticalSection(&SHELL32_SicCS);
return ret;
}
示例14: dllGetFullPathNameW
extern "C" DWORD WINAPI dllGetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart)
{
#ifdef TARGET_WINDOWS
if (!lpFileName) return 0;
if(wcsstr(lpFileName, L"://"))
{
size_t length = wcslen(lpFileName);
if (nBufferLength < (length + 1))
return length + 1;
else
{
wcscpy(lpBuffer, lpFileName);
if(lpFilePart)
{
wchar_t* s1 = wcsrchr(lpBuffer, '\\');
wchar_t* s2 = wcsrchr(lpBuffer, '/');
if(s2 && s1 > s2)
*lpFilePart = s1 + 1;
else if(s1 && s2 > s1)
*lpFilePart = s2 + 1;
else
*lpFilePart = lpBuffer;
}
return length;
}
}
return GetFullPathNameW(lpFileName, nBufferLength, lpBuffer, lpFilePart);
#else
not_implement("kernel32.dll fake function GetFullPathNameW called\n"); //warning
return 0;
#endif
}
示例15: gitwin_to_utf16
char *p_realpath(const char *orig_path, char *buffer)
{
int ret;
wchar_t* orig_path_w = gitwin_to_utf16(orig_path);
wchar_t* buffer_w = (wchar_t*)git__malloc(GIT_PATH_MAX * sizeof(wchar_t));
ret = GetFullPathNameW(orig_path_w, GIT_PATH_MAX, buffer_w, NULL);
git__free(orig_path_w);
if (!ret || ret > GIT_PATH_MAX) {
buffer = NULL;
goto done;
}
if (buffer == NULL) {
int buffer_sz = WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, NULL, 0, NULL, NULL);
if (!buffer_sz ||
!(buffer = (char *)git__malloc(buffer_sz)) ||
!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, buffer_sz, NULL, NULL))
{
git__free(buffer);
buffer = NULL;
}
} else {
if (!WideCharToMultiByte(CP_UTF8, 0, buffer_w, -1, buffer, GIT_PATH_MAX, NULL, NULL))
buffer = NULL;
}
done:
git__free(buffer_w);
if (buffer)
git_path_mkposix(buffer);
return buffer;
}