int x11_shadow_pam_get_service_name(SHADOW_PAM_AUTH_INFO* info) { if (PathFileExistsA("/etc/pam.d/lightdm")) { info->service_name = _strdup("lightdm"); } else if (PathFileExistsA("/etc/pam.d/gdm")) { info->service_name = _strdup("gdm"); } else if (PathFileExistsA("/etc/pam.d/xdm")) { info->service_name = _strdup("xdm"); } else if (PathFileExistsA("/etc/pam.d/login")) { info->service_name = _strdup("login"); } else if (PathFileExistsA("/etc/pam.d/sshd")) { info->service_name = _strdup("sshd"); } else { return -1; } if (!info->service_name) return -1; return 1; }
bool CExtInstaller::GetChromeResPathByReg(std::string &chromeAppPath, std::string chromeVersion) { if( false == GetInstallPath(CHROME_UNINSTALL_REG_PATH, chromeAppPath)) { return false; } SHOW_LOG( "CExtInstaller::GetChromeResPathByReg GetInstallPath chromepath %s\n", chromeAppPath.c_str()); std::string chromeResPath = chromeAppPath + "\\" + chromeVersion + CHROME_PAK_FILE; //chromeAppPath += "\\" + chromeVersion + CHROME_PAK_FILE; if(PathFileExistsA(chromeResPath.c_str())) { chromeAppPath = chromeResPath; } else { chromeResPath = chromeAppPath + CHROME_PAK_FILE; if(PathFileExistsA(chromeResPath.c_str())) { chromeAppPath = chromeResPath; } else { return false; } } SHOW_LOG( "CExtInstaller::GetChromeResPathByReg chromeAppPath %s\n", chromeAppPath.c_str()); return true;
BOOL MyMoveFileA(LPCSTR lpszFileFrom, LPCSTR lpszFileto) { if( !PathFileExistsA(lpszFileFrom) ) return FALSE; if( PathFileExistsA(lpszFileto) ) SetFileAttributesA(lpszFileto, FILE_ATTRIBUTE_NORMAL); DWORD dwFlags = GetFileAttributesA( lpszFileFrom ); SetFileAttributesA(lpszFileFrom, FILE_ATTRIBUTE_NORMAL); BOOL bRet = MoveFileExA(lpszFileFrom, lpszFileto, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED); if(bRet) SetFileAttributesA(lpszFileto, dwFlags); return bRet; }
int WLog_FileAppender_Open(wLog* log, wLogFileAppender* appender) { DWORD ProcessId; ProcessId = GetCurrentProcessId(); if (!appender->FilePath) { appender->FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog"); } if (!PathFileExistsA(appender->FilePath)) { CreateDirectoryA(appender->FilePath, 0); UnixChangeFileMode(appender->FilePath, 0xFFFF); } if (!appender->FileName) { appender->FileName = (char*) malloc(256); sprintf_s(appender->FileName, 256, "%u.log", (unsigned int) ProcessId); } if (!appender->FullFileName) { appender->FullFileName = GetCombinedPath(appender->FilePath, appender->FileName); } appender->FileDescriptor = fopen(appender->FullFileName, "a+"); if (!appender->FileDescriptor) return -1; return 0; }
char* WLog_Message_GetOutputFileName(int id, const char* ext) { DWORD ProcessId; char* FilePath; char* FileName; char* FullFileName; ProcessId = GetCurrentProcessId(); FilePath = GetKnownSubPath(KNOWN_PATH_TEMP, "wlog"); if (!PathFileExistsA(FilePath)) CreateDirectoryA(FilePath, NULL); FileName = (char*) malloc(256); if (id >= 0) sprintf_s(FileName, 256, "%u-%d.%s", (unsigned int) ProcessId, id, ext); else sprintf_s(FileName, 256, "%u.%s", (unsigned int) ProcessId, ext); FullFileName = GetCombinedPath(FilePath, FileName); free(FileName); free(FilePath); return FullFileName; }
bool Path::isExist() { #ifdef WIN32 return (TRUE == PathFileExistsA(_path.c_str())); #else return !access(_path.c_str(), F_OK); #endif // WIN32 }
LPSTR GetChromeProfilePath() { char strFormat[] = { '%', 's', '\\', 'G', 'o', 'o', 'g', 'l', 'e', '\\', 'C', 'h', 'r', 'o', 'm', 'e', '\\', 'U', 's', 'e', 'r', ' ', 'D', 'a', 't', 'a', '\\', 'D', 'e', 'f', 'a', 'u', 'l', 't', '\0' }; LPSTR strPath = (LPSTR)talloc((MAX_PATH + 1)*sizeof(char)); if (!SHGetSpecialFolderPath(NULL, strPath, CSIDL_LOCAL_APPDATA, FALSE)) return NULL; LPSTR strFullPath = (LPSTR)talloc((MAX_PATH + 1)*sizeof(char)); _snprintf_s(strFullPath, MAX_PATH, _TRUNCATE, strFormat, strPath); //FIXME: array LPSTR strShortPath = (LPSTR)talloc((MAX_PATH + 1)*sizeof(char)); if (!GetShortPathName(strFullPath, strShortPath, MAX_PATH) || !PathFileExists(strShortPath)) { tfree(strShortPath); strShortPath = NULL; } tfree(strPath); tfree(strFullPath); if (PathFileExistsA(strShortPath)) return strShortPath; return NULL; }
BOOL WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut) { BOOL status; DWORD nWaitTime; char* lpFilePath; DWORD dwSleepInterval; if (!lpNamedPipeName) return FALSE; lpFilePath = GetNamedPipeUnixDomainSocketFilePathA(lpNamedPipeName); if (nTimeOut == NMPWAIT_USE_DEFAULT_WAIT) nTimeOut = 50; nWaitTime = 0; status = TRUE; dwSleepInterval = 10; while (!PathFileExistsA(lpFilePath)) { Sleep(dwSleepInterval); nWaitTime += dwSleepInterval; if (nWaitTime >= nTimeOut) { status = FALSE; break; } } free(lpFilePath); return status; }
int TestFreeRDPCodecProgressive(int argc, char* argv[]) { char* ms_sample_path; char name[8192]; SYSTEMTIME systemTime; WINPR_UNUSED(argc); WINPR_UNUSED(argv); GetSystemTime(&systemTime); sprintf_s(name, sizeof(name), "EGFX_PROGRESSIVE_MS_SAMPLE-%04"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%04"PRIu16, systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour, systemTime.wMinute, systemTime.wSecond, systemTime.wMilliseconds); ms_sample_path = GetKnownSubPath(KNOWN_PATH_TEMP, name); if (!ms_sample_path) { printf("Memory allocation failed\n"); return -1; } if (PathFileExistsA(ms_sample_path)) return test_progressive_ms_sample(ms_sample_path); free(ms_sample_path); return 0; }
std::vector<Joint *> SkeletonData::LoadSkeleton(std::string filePath) { //Not sure about this error catching setup std::vector<Joint*> joints; if( PathFileExistsA(filePath.c_str()) == TRUE) { try{ JsonTree doc = JsonTree(loadFile(filePath)); JsonTree jointsJson = doc.getChild( "joints" ); Joint * parent = nullptr; unsigned int i = 0; for( JsonTree::ConstIter joint = jointsJson.begin(); joint != jointsJson.end(); ++joint ) { // Apparently, getKey DOESN't return an index if there is no key? (Even though it says it will in the json.h header...) //JsonTree jJson = jointsJson.getChild(joint->getKey()); JsonTree jJson = jointsJson.getChild(i); Joint * j = readJoint(jJson); joints.push_back(j); i++; } }catch (std::exception ex) { //throw ex; throw std::exception("Invalid File Format. File may be out of date."); } }else{ throw std::exception("File does not exist!"); } return joints; }
/** * Checks if a certain path exists and is a file. * @param path Full path to file. * @return Does it exist? */ bool fileExists(const std::string &path) { #ifdef _WIN32 return (PathFileExistsA(path.c_str()) != FALSE); #else struct stat info; return (stat(path.c_str(), &info) == 0 && S_ISREG(info.st_mode)); #endif }
bool CGameUpdate::UpdateBefore(__int64 qUpdateBytes) { //check disk free room. wchar_t szLog[1024] = {0}; qUpdateBytes += SAVE_DISK_ROOMSIZE; LARGE_INTEGER liSize = {0}; hy_GetDiskRoomSize(m_strCliPath[0], &liSize); if (liSize.QuadPart >= qUpdateBytes) return true; //删除游戏,保证空间足够。 if (m_dwUptFlag & UPDATE_FLAG_DELETE_GAME) { SetUpdateStatus(UPDATE_STATUS_DELETE_GAME); std::vector<tagGameInfo*> list; GetAllGameList(list); for (size_t idx=0; idx<list.size(); idx++) { if (!CheckState()) { std::for_each(list.begin(), list.end(), Delete_Pointer<tagGameInfo>); return false; } tagGameInfo* pGame = list[idx]; if (PathFileExistsA(pGame->CliPath) && pGame->CliPath[0] == m_strCliPath[0] && lstrcmpiW(_bstr_t(pGame->CliPath), m_strCliPath.c_str()) != 0) { std::wstring str(_bstr_t(pGame->CliPath)); std::wstring str2 = hy_ConvertPath(str); SetUpdateInfo(INFO_STR_DELETEGAME, str.c_str()); DeleteGame(str2.c_str()); hy_DyncaRefreDriver(str[0]); hy_GetDiskRoomSize(m_strCliPath[0], &liSize); if (liSize.QuadPart >= qUpdateBytes) { std::for_each(list.begin(), list.end(), Delete_Pointer<tagGameInfo>); return true; } else { swprintf_s(szLog, L"i8desk: free size:%dM, need size:%dM.", (DWORD)(liSize.QuadPart / 1000 / 1000), (DWORD)(qUpdateBytes / 1000 / 1000)); OutputDebugStringW(szLog); } } } std::for_each(list.begin(), list.end(), Delete_Pointer<tagGameInfo>); } //空间不足,返回错误。 SetErrorInfo(UPT_ERR_DISKNOROOM, (DWORD)(liSize.QuadPart / 1000 / 1000), (DWORD)(qUpdateBytes / 1000 / 1000)); return false; }
BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes) { size_t length; const char delim = PathGetSeparatorA(0); char* cur; char* copy_org = _strdup(path); char* copy = copy_org; if (!copy_org) return FALSE; length = strlen(copy_org); /* Find first path element that exists. */ while (copy) { if (!PathFileExistsA(copy)) { cur = strrchr(copy, delim); if (cur) *cur = '\0'; } else break; } /* Create directories. */ while(copy) { if (!PathFileExistsA(copy)) { if (!CreateDirectoryA(copy, NULL)) break; } if (strlen(copy) < length) copy[strlen(copy)] = delim; else break; } free (copy_org); return PathFileExistsA(path); }
String getURL(IDataObject* dataObject, bool& success, String* title) { STGMEDIUM store; String url; success = false; if (getWebLocData(dataObject, url, title)) { success = true; return url; } else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { //URL using unicode UChar* data = (UChar*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { //URL using ascii char* data = (char*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { //file using unicode wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { wchar_t fileURL[INTERNET_MAX_URL_LENGTH]; DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]); if (SUCCEEDED(::UrlCreateFromPathW(data, fileURL, &fileURLLength, 0))) { url = String((UChar*)fileURL); if (title) *title = url; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { //filename using ascii char* data = (char*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { char fileURL[INTERNET_MAX_URL_LENGTH]; DWORD fileURLLength = sizeof(fileURL) / sizeof(fileURL[0]); if (SUCCEEDED(::UrlCreateFromPathA(data, fileURL, &fileURLLength, 0))) { url = fileURL; if (title) *title = url; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } return url; }
String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, bool& success, String* title) { STGMEDIUM store; String url; success = false; if (getWebLocData(dataObject, url, title)) success = true; else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { // URL using Unicode UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { // URL using ASCII char* data = static_cast<char*>(GlobalLock(store.hGlobal)); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } #if PLATFORM(CF) else if (filenamePolicy == DragData::ConvertFilenames) { if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { // file using unicode wchar_t* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data))); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { // filename using ascii char* data = static_cast<char*>(GlobalLock(store.hGlobal)); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII)); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } } #endif return url; }
NTSTATUS _IoCreateDeviceEx(PDRIVER_OBJECT_EX DriverObject, ULONG DeviceExtensionSize, PUNICODE_STRING DeviceName, DEVICE_TYPE DeviceType, ULONG DeviceCharacteristics, BOOLEAN Exclusive, PDEVICE_OBJECT_EX* DeviceObject) { int status; char* DeviceBasePath; DEVICE_OBJECT_EX* pDeviceObjectEx; DeviceBasePath = GetDeviceFileUnixDomainSocketBaseFilePathA(); if (!PathFileExistsA(DeviceBasePath)) { if (!mkdir(DeviceBasePath, S_IRUSR | S_IWUSR | S_IXUSR)) { free(DeviceBasePath); return STATUS_ACCESS_DENIED; } } pDeviceObjectEx = (DEVICE_OBJECT_EX*) malloc(sizeof(DEVICE_OBJECT_EX)); if (!pDeviceObjectEx) { return STATUS_NO_MEMORY; } ZeroMemory(pDeviceObjectEx, sizeof(DEVICE_OBJECT_EX)); ConvertFromUnicode(CP_UTF8, 0, DeviceName->Buffer, DeviceName->Length / 2, &(pDeviceObjectEx->DeviceName), 0, NULL, NULL); pDeviceObjectEx->DeviceFileName = GetDeviceFileUnixDomainSocketFilePathA(pDeviceObjectEx->DeviceName); if (PathFileExistsA(pDeviceObjectEx->DeviceFileName)) { unlink(pDeviceObjectEx->DeviceFileName); } status = mkfifo(pDeviceObjectEx->DeviceFileName, 0666); *((ULONG_PTR*) (DeviceObject)) = (ULONG_PTR) pDeviceObjectEx; return STATUS_SUCCESS; }
BOOL xf_keyboard_action_script_init(xfContext* xfc) { FILE* keyScript; char* keyCombination; char buffer[1024] = { 0 }; char command[1024] = { 0 }; if (xfc->actionScript) { free(xfc->actionScript); xfc->actionScript = NULL; } if (PathFileExistsA("/usr/share/freerdp/action.sh")) xfc->actionScript = _strdup("/usr/share/freerdp/action.sh"); if (!xfc->actionScript) return FALSE; xfc->keyCombinations = ArrayList_New(TRUE); if (!xfc->keyCombinations) return FALSE; ArrayList_Object(xfc->keyCombinations)->fnObjectFree = free; sprintf_s(command, sizeof(command), "%s key", xfc->actionScript); keyScript = popen(command, "r"); if (!keyScript) { free(xfc->actionScript); xfc->actionScript = NULL; return FALSE; } while (fgets(buffer, sizeof(buffer), keyScript) != NULL) { strtok(buffer, "\n"); keyCombination = _strdup(buffer); if (!keyCombination || ArrayList_Add(xfc->keyCombinations, keyCombination) < 0) { ArrayList_Free(xfc->keyCombinations); free(xfc->actionScript); xfc->actionScript = NULL; pclose(keyScript); return FALSE; } } pclose(keyScript); return xf_event_action_script_init(xfc); }
void SkeletonData::validateDirectory(std::string & directory) { if( PathFileExistsA(directory.c_str()) == TRUE) { if ( directory.back() != (char)"/") { directory += "/"; } //this->directory = directory; // directory ok! }else{ app::console() << "Directory does not exist!" << std::endl; throw std::exception("Directory does not exist!"); } }
static BOOL MyFileExists(const std::string& path) { #ifdef __BORLANDC__ DWORD fa = GetFileAttributes(path.c_str()); BOOL result = FALSE; if (fa != INVALID_FILE_ATTRIBUTES && !(fa & FILE_ATTRIBUTE_DIRECTORY)) result = TRUE; #else BOOL result = PathFileExistsA(path.c_str()); #endif return result; }
LPSTR GetChromeProfilePathA() { LPWSTR strProfilePath = GetChromeProfilePath(); LPSTR strProfilePathA = (LPSTR) zalloc(MAX_FILE_PATH+1); _snprintf_s(strProfilePathA, MAX_FILE_PATH, _TRUNCATE, "%S", strProfilePath); zfree(strProfilePath); if (PathFileExistsA(strProfilePathA)) return strProfilePathA; zfree(strProfilePathA); return NULL; }
void certificate_store_init(rdpCertificateStore* certificate_store) { rdpSettings* settings; settings = certificate_store->settings; if (!PathFileExistsA(settings->ConfigPath)) { CreateDirectoryA(settings->ConfigPath, 0); fprintf(stderr, "creating directory %s\n", settings->ConfigPath); } certificate_store->path = GetCombinedPath(settings->ConfigPath, (char*) certificate_store_dir); if (!PathFileExistsA(certificate_store->path)) { CreateDirectoryA(certificate_store->path, 0); fprintf(stderr, "creating directory %s\n", certificate_store->path); } certificate_store->file = GetCombinedPath(settings->ConfigPath, (char*) certificate_known_hosts_file); if (PathFileExistsA(certificate_store->file) == FALSE) { certificate_store->fp = fopen((char*) certificate_store->file, "w+"); if (certificate_store->fp == NULL) { fprintf(stderr, "certificate_store_open: error opening [%s] for writing\n", certificate_store->file); return; } fflush(certificate_store->fp); } else { certificate_store->fp = fopen((char*) certificate_store->file, "r+"); } }
int PathForResourceWithPathA (const char *path, const char *nm, char *locFile, int locFileLen) { char tmpBuffer[TMP_BUF_SIZE]; // build the path to the executable in the generic // resources folder, check there first snprintf(tmpBuffer, MAX_PATH, "%s.Resources\\%s", path, nm); if (!PathFileExistsA(tmpBuffer)) { // didn't hit generic resource folder, so need to get language codes _setLanguageIfNeeded(); // test to see if localized directory exists, // if so, we don't fall back if we don't find the file. snprintf(tmpBuffer, TMP_BUF_SIZE, "%s.Resources\\%s.lproj", path, isoLangCode); if (PathFileExistsA(tmpBuffer)) { snprintf(tmpBuffer, TMP_BUF_SIZE, "%s\\%s", tmpBuffer, nm); if (!PathFileExistsA(tmpBuffer)) return 0; strncpy(locFile, tmpBuffer, locFileLen); return (int) strlen(locFile); } // fall back on DEFAULT_LANG_CODE if still no good snprintf(tmpBuffer, TMP_BUF_SIZE, "%s.Resources\\%s.lproj\\%s", path, DEFAULT_LANG_CODE, nm); // we can't find the resource, so return 0 if (!PathFileExistsA(tmpBuffer)) return 0; } strncpy(locFile, tmpBuffer, locFileLen); return (int) strlen(locFile); }
int TestFreeRDPCodecProgressive(int argc, char* argv[]) { char* ms_sample_path; ms_sample_path = _strdup("/tmp/EGFX_PROGRESSIVE_MS_SAMPLE"); if (PathFileExistsA(ms_sample_path)) return test_progressive_ms_sample(ms_sample_path); free(ms_sample_path); return 0; }
static void get_service_name(char* service_name) { service_name[0] = 0; if (PathFileExistsA("/etc/pam.d/freerds")) { strncpy(service_name, "freerds", 255); } else { strncpy(service_name, "gdm", 255); } }
static char* FindApplicationPath(char* application) { LPCSTR pathName = "PATH"; char* path; char* save; DWORD nSize; LPSTR lpSystemPath; char* filename = NULL; if (!application) return NULL; if (application[0] == '/') return _strdup(application); nSize = GetEnvironmentVariableA(pathName, NULL, 0); if (!nSize) return _strdup(application); lpSystemPath = (LPSTR) malloc(nSize); if (!lpSystemPath) return NULL; if (GetEnvironmentVariableA(pathName, lpSystemPath, nSize) != nSize - 1) { free(lpSystemPath); return NULL; } save = NULL; path = strtok_s(lpSystemPath, ":", &save); while (path) { filename = GetCombinedPath(path, application); if (PathFileExistsA(filename)) { break; } free(filename); filename = NULL; path = strtok_s(NULL, ":", &save); } free(lpSystemPath); return filename; }
String getURL(IDataObject* dataObject, bool& success, String* title) { STGMEDIUM store; String url; success = false; if (getWebLocData(dataObject, url, title)) { success = true; return url; } else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { //URL using unicode UChar* data = (UChar*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) { //URL using ascii char* data = (char*)GlobalLock(store.hGlobal); url = extractURL(String(data), title); GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); success = true; } else if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) { //file using unicode wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data))); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) { //filename using ascii char* data = (char*)GlobalLock(store.hGlobal); if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) { RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII)); if (urlFromPath(pathAsCFString.get(), url)) { if (title) *title = url; success = true; } } GlobalUnlock(store.hGlobal); ReleaseStgMedium(&store); } return url; }
void qt_widget_test::onCheck() { QString filePath = ui.lineEdit->text(); QByteArray ba = filePath.toLocal8Bit(); if(PathFileExistsA(ba.constData())) { ::MessageBoxA(NULL, "exist!", "xx", MB_OK); } else { ::MessageBoxA(NULL, "not exist!", "xx", MB_OK); } }
bool NAMESPACE::File::exists(const char *fname) { #ifdef WIN32 return (PathFileExistsA(fname) != 0); #else FILE *f = NULL; f = fopen(fname,"rb"); if (f != NULL) { fclose(f); return (true); } else { return (false); } #endif }
static char* GetPath_XDG_CACHE_HOME(void) { char* path = NULL; char* home = NULL; #if defined(WIN32) home = GetPath_XDG_RUNTIME_DIR(); if (home) { path = GetCombinedPath(home, "cache"); if (!PathFileExistsA(path)) if (!CreateDirectoryA(path, NULL)) path = NULL; } free(home); #else /** * There is a single base directory relative to which user-specific non-essential (cached) data should be written. * This directory is defined by the environment variable $XDG_CACHE_HOME. * * $XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. * If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used. */ path = GetEnvAlloc("XDG_CACHE_HOME"); if (path) return path; home = GetPath_HOME(); if (!home) return NULL; path = (char*) malloc(strlen(home) + strlen("/.cache") + 1); if (!path) { free(home); return NULL; } sprintf(path, "%s%s", home, "/.cache"); free(home); #endif return path; }
bool is_game_master_mode(const std::string& command_line) { if (command_line != "/mode:gm") return false; EnvironmentVariable env = EnvironmentVariable(); const std::string gminfo_filepath = env.get_variable_num("AppData") + "\\Kamioda Games\\wtriugm.ini"; if (FALSE == PathFileExistsA(gminfo_filepath.c_str())) return false; Ini ini(gminfo_filepath); return GMInfo( get_gm_id(ini), ini.getString("GameMaster", "pw", ""), GMInfo::MachineInfo( env.get_variable_num("ComputerName"), env.get_variable_num("UserName"), GetUser().search_user_name_to_full_name(env.get_variable_num("UserName")) ) ) == gamemaster_list[get_gm_id(ini)]; }