//--------------------------------------------------------------------------- void __fastcall TChatRoomForm::ProxyButtonClick(TObject *Sender) { TDSJavaScriptProxyWriter *JSProxy; String OutputFile; OutputFile = ExpandFileName(ServerContainerForm->ChatRoomFileDispatcher->RootDirectory); JSProxy = new TDSJavaScriptProxyWriter(); try { if (!DirectoryExists(OutputFile)) ForceDirectories(OutputFile); if ( !AnsiEndsStr("\\", OutputFile) && !AnsiEndsStr("/", OutputFile)) OutputFile = OutputFile + Sysutils::PathDelim; //put the proxy file in a subdirectory of the root folder OutputFile = OutputFile + Sysutils::PathDelim + "webfiles" + Sysutils::PathDelim; //name the proxy file OutputFile = OutputFile + "JSProxy.js"; ProxyConnection->Connected = true; JSProxy->UpdateJSProxyFile(ProxyConnection->DBXConnection, OutputFile); ProxyConnection->Close(); } __finally { JSProxy->Free(); } }
//--------------------------------------------------------------------------- void __fastcall TfrmMain::FormCreate(TObject *Sender) { cb_key1->Items->AddStrings(Keys); cb_key2->Items->AddStrings(Keys); cb_key3->Items->AddStrings(Keys); cb_key4->Items->AddStrings(Keys); cb_pick->Items->AddStrings(Keys); cb_att->Items->AddStrings(Keys); cb_key1->ItemIndex = 0; cb_key1->ItemIndex = 1; cb_key1->ItemIndex = 2; cb_key1->ItemIndex = 3; cb_pick->ItemIndex = 4; cb_att->ItemIndex = 5; UI->Enabled = true; SendMessage(FmxHandleToHWND(this->Handle), WM_SETICON, ICON_BIG, (LPARAM) hIcon1); SendMessage(FmxHandleToHWND(this->Handle), WM_SETICON, ICON_SMALL, (LPARAM) hIcon1); SendMessage(FmxHandleToHWND(this->Handle), WM_SETICON, ICON_SMALL2, (LPARAM) hIcon1); this->Caption = String("RwBox ++ - ") + GameAccount; if( !DirectoryExists( String(LoginerPath) + "\\Data\\" + GameAccount)) { CreateDir(String(LoginerPath) + "\\Data\\"); CreateDir(String(LoginerPath) + "\\Data\\" + GameAccount + "\\"); } Load->Enabled = true; }
void __fastcall TForm1::TBItem1Click(TObject *Sender) { _di_IXMLNode ANode; AnsiString fname; ArticleList->Clear(); if(XMLDoc->FileName == NULL) { Application->MessageBoxA("News Turkey can't get news unless a source to get news from is selected.", "News Turkey Error", NULL); return; } XMLDoc->Active = TRUE; if(XMLDoc->Active == FALSE) { //This is to predvent Access Violations if there is a problem parsing the file return; } ListSources(); ANode = RSSChannel->ChildNodes->FindNode("title"); if(DirectoryExists(ANode->Text) == FALSE) { CreateDir(ANode->Text); } XMLDoc->SaveToFile(fname.sprintf("CNET News.com - Front Door\\feed.xml")); XMLDoc->Active = FALSE; }
//--------------------------------------------------------------------------- AnsiString __fastcall GetMatlab6Root(void) { AnsiString S = ""; __TRY TRegistry *RR = new TRegistry(); try { // Для Matlab 6.5 RR->RootKey = HKEY_CLASSES_ROOT; if (RR->OpenKey("\\Matlab.Application.Single.6\\CLSID",false)) S = RR->ReadString(""); if (RR->OpenKey("\\CLSID\\"+S+"\\LocalServer32",false)) S = RR->ReadString(""); int ps = S.AnsiPos("matlab.exe"); if (ps) { S = S.SubString( 1, ps-2); // S содержит размещение matlab.exe (полный путь) S = ExtractFileDir(S); S = ExtractFileDir(S); } } __finally { delete RR; } if (!DirectoryExists(S)) { S = ""; } __CATCH return S; }
bool IPlatformFile::DeleteDirectoryRecursively(const TCHAR* Directory) { class FRecurse : public FDirectoryVisitor { public: IPlatformFile& PlatformFile; FRecurse(IPlatformFile& InPlatformFile) : PlatformFile(InPlatformFile) { } virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory) { if (bIsDirectory) { PlatformFile.IterateDirectory(FilenameOrDirectory, *this); PlatformFile.DeleteDirectory(FilenameOrDirectory); } else { PlatformFile.SetReadOnly(FilenameOrDirectory, false); PlatformFile.DeleteFile(FilenameOrDirectory); } return true; // continue searching } }; FRecurse Recurse(*this); Recurse.Visit(Directory, true); return !DirectoryExists(Directory); }
void Runtime::Debugger::Debug() { wcout << L"-------------------------------------" << endl; wcout << L"Objeck " << VERSION_STRING << L" - Interactive Debugger" << endl; wcout << L"-------------------------------------" << endl << endl; if(FileExists(program_file, true) && DirectoryExists(base_path)) { wcout << L"loaded executable: file='" << program_file << L"'" << endl; wcout << L"source files: path='" << base_path << L"'" << endl << endl; // clear arguments arguments.clear(); arguments.push_back(L"obr"); arguments.push_back(program_file); } else { wcerr << L"unable to load executable or locate base path." << endl; exit(1); } // enter feedback loop ClearProgram(); wcout << L"> "; while(true) { wstring line; getline(wcin, line); if(line.size() > 0) { ProcessCommand(line); wcout << L"> "; } } }
void ComposerShellMenu::SetStatus() { m_Status.invalid = false; // See if we are in vendor directory std::wstring path(m_TargetDir + L"\\"); size_t pos = path.rfind(L"\\vendor\\"); if (std::wstring::npos != pos) { path.resize(pos); m_Status.invalid = DirectoryExists(path + L"\\vendor\\composer"); } if (m_Status.invalid) return; m_Status.composer = FileExists(m_TargetDir + L"\\composer.json"); if (m_Status.composer) { // We have a composer.json. Check if we have installed it m_Status.installed = FileExists(m_TargetDir + L"\\vendor\\composer\\installed.json"); /* //std::wstring composerJson = ReadComposerJson(); m_Status.project = std::wstring::npos == composerJson.find(L"\"name\":"); m_Status.package = !m_Status.project; */ } }
bool IsSvnDir2(const String& p) { // this is a cope of usvn/IsSvnDir to avoid modular issues if(IsNull(p)) return false; if(DirectoryExists(AppendFileName(p, ".svn")) || DirectoryExists(AppendFileName(p, "_svn"))) return true; String path = p; String path0; while(path != path0) { path0 = path; path = GetFileFolder(path); if(DirectoryExists(AppendFileName(path, ".svn"))) return true; } return false; }
/* * worker_fetch_partition_file fetches a partition file from the remote node. * The function assumes an upstream compute task depends on this partition file, * and therefore directly fetches the file into the upstream task's directory. */ Datum worker_fetch_partition_file(PG_FUNCTION_ARGS) { uint64 jobId = PG_GETARG_INT64(0); uint32 partitionTaskId = PG_GETARG_UINT32(1); uint32 partitionFileId = PG_GETARG_UINT32(2); uint32 upstreamTaskId = PG_GETARG_UINT32(3); text *nodeNameText = PG_GETARG_TEXT_P(4); uint32 nodePort = PG_GETARG_UINT32(5); char *nodeName = NULL; /* remote filename is <jobId>/<partitionTaskId>/<partitionFileId> */ StringInfo remoteDirectoryName = TaskDirectoryName(jobId, partitionTaskId); StringInfo remoteFilename = PartitionFilename(remoteDirectoryName, partitionFileId); /* local filename is <jobId>/<upstreamTaskId>/<partitionTaskId> */ StringInfo taskDirectoryName = TaskDirectoryName(jobId, upstreamTaskId); StringInfo taskFilename = TaskFilename(taskDirectoryName, partitionTaskId); /* * If we are the first function to fetch a file for the upstream task, the * task directory does not exist. We then lock and create the directory. */ bool taskDirectoryExists = DirectoryExists(taskDirectoryName); if (!taskDirectoryExists) { InitTaskDirectory(jobId, upstreamTaskId); } nodeName = text_to_cstring(nodeNameText); FetchRegularFile(nodeName, nodePort, remoteFilename, taskFilename); PG_RETURN_VOID(); }
// Check if the specified directory exists bool MassStorage::DirectoryExists(const char *path) const { // Remove any trailing '/' from the directory name, it sometimes (but not always) confuses f_opendir String<MaxFilenameLength> loc; loc.copy(path); return DirectoryExists(loc.GetRef()); }
SString SharedUtil::MakeUniquePath(const SString& strInPathFilename) { const SString strPathFilename = PathConform(strInPathFilename); SString strBeforeUniqueChar, strAfterUniqueChar; SString strPath, strFilename; ExtractFilename(strPathFilename, &strPath, &strFilename); SString strMain, strExt; if (ExtractExtension(strFilename, &strMain, &strExt)) { strBeforeUniqueChar = PathJoin(strPath, strMain); strAfterUniqueChar = "." + strExt; } else { strBeforeUniqueChar = strPathFilename; strAfterUniqueChar = ""; } SString strTest = strPathFilename; int iCount = 1; #ifdef WIN32 while (GetFileAttributes(strTest) != INVALID_FILE_ATTRIBUTES) #else while (DirectoryExists(strTest) || FileExists(strTest)) #endif { strTest = SString("%s_%d%s", strBeforeUniqueChar.c_str(), iCount++, strAfterUniqueChar.c_str()); } return strTest; }
//--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- __fastcall TDialogProjectNew::TDialogProjectNew(TComponent* Owner) : TForm(Owner) { TemplatePath = Usul()->Ini->ReadString("Settings", "PathTemplatesProjects", TemplatePath = Usul()->Path + "\\Templates\\Projects"); PageControl->ActivePageIndex = 0; TSearchRec SearchRec; if (FindFirst(TemplatePath + "\\*", faDirectory, SearchRec) == 0) { do { if (SearchRec.Name[1] != '.') { TListItem *ListItem = ListView->Items->Add(); ListItem->Caption = SearchRec.Name; ListItem->ImageIndex = 1; } } while (FindNext(SearchRec) == 0); } FindClose(SearchRec); if (Usul()->HasWriteAccessToExeDirectrory()) Edit->Text = Usul()->Path + "\\New project"; else Edit->Text = Usul()->PathDocuments + "\\New project"; for (int I = 2;;I++) { bool IsDirectoryExists = DirectoryExists(Edit->Text); bool IsFileExists = FileExists(Edit->Text); if (!IsDirectoryExists && !IsFileExists) break; Edit->Text = Usul()->Path + "\\New project" + String(I); } }
void TProfileToGui::_removeNonExistentDirsFromList(std::vector<String> &list) { unsigned int i = 0; while (i < list.size()) { if (!DirectoryExists(list[i])) { f_Main->statusNotif( ASPF(_("Directory does not exist: %s"), ecc::QuoteStr(list[i])) + " - "); ++i; if (PGlobals->RemoveNonExistingSourceDirs) { std::vector<String>::iterator pos = &list[i]; list.erase(pos); f_Main->statusNotif( _("Removed from Profile."), -1); } else { f_Main->statusNotif( _("Ok."), -1); ++i; } } else ++i; } }
void populate_dir (void) { char buf[MAX_PATH]; char mask[MAX_MASK_LEN]; GetWindowText(GetDlgItem(hMainWindow, IDC_MANPATH), buf, sizeof(buf)); GetWindowText(GetDlgItem(hMainWindow, IDC_MASK), mask, sizeof(mask)); if (!DirectoryExists(buf)) { current_path_to_edit (); strcpy (buf, CurrentPath); } else { size_t off; off = strlen(buf); if ((off) && (buf[off-1] != '\\') && (buf[off-1] != '/')) { buf[off] = '\\'; buf[off+1] = 0; } strcpy (CurrentPath, buf); current_path_to_edit (); } DlgDirListComboBox(hMainWindow, buf, IDC_DRIVES, 0, DDL_DRIVES); DlgDirList (hMainWindow, buf, IDC_DIRS, 0, DDL_DIRECTORY + DDL_EXCLUSIVE); /* if you want to show only files that match mask - uncomment next line */ //strcat (buf, mask); DlgDirList (hMainWindow, buf, IDC_FILES, IDC_REALPATH, 0x27); snprintf (mask, sizeof(mask), "[-%c-]", 'a' +_getdrive() - 1); ComboBox_SelectString (GetDlgItem(hMainWindow, IDC_DRIVES), 0, mask); }
void ProjectConfigDialog::onSelectScriptFile(void) { char buff[MAX_PATH + 1] = {0}; char projdir[MAX_PATH + 1] = {0}; GetDlgItemTextA(m_hwndDialog, IDC_EDIT_PROJECT_DIR, projdir, MAX_PATH); OPENFILENAMEA ofn = {0}; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = m_hwndDialog; ofn.lpstrFilter = "Lua Script File (*.lua)\0*.lua\0"; ofn.lpstrTitle = "Select Script File"; if (DirectoryExists(projdir)) { ofn.lpstrInitialDir = projdir; } ofn.Flags = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; ofn.lpstrFile = buff; ofn.nMaxFile = MAX_PATH; if (GetOpenFileNameA(&ofn)) { m_project.setScriptFile(buff); updateScriptFile(); } }
static int CheckDataDirectory(TCascStorage * hs, TCHAR * szDirectory) { TCHAR * szDataPath; int nError = ERROR_FILE_NOT_FOUND; // Try all known subdirectories for(size_t i = 0; DataDirs[i] != NULL; i++) { // Create the eventual data path szDataPath = CombinePath(szDirectory, DataDirs[i]); if(szDataPath != NULL) { // Does that directory exist? if(DirectoryExists(szDataPath)) { hs->szDataPath = szDataPath; return ERROR_SUCCESS; } // Free the data path CASC_FREE(szDataPath); } } return nError; }
// // Ensure all directories exist to the file // void SharedUtil::MakeSureDirExists ( const SString& strPath ) { std::vector < SString > parts; PathConform ( strPath ).Split ( PATH_SEPERATOR, parts ); // Find first dir that already exists int idx = parts.size () - 1; for ( ; idx >= 0 ; idx-- ) { SString strTemp = SString::Join ( PATH_SEPERATOR, parts, 0, idx ); if ( DirectoryExists ( strTemp ) ) break; } // Make non existing dirs only idx++; for ( ; idx < (int)parts.size () ; idx++ ) { SString strTemp = SString::Join ( PATH_SEPERATOR, parts, 0, idx ); // Call mkdir on this path #ifdef WIN32 mkdir ( strTemp ); #else mkdir ( strTemp ,0775 ); #endif } }
bool CFileSystemWin32::CreateDirectory(const nString& Path) { #ifdef UNICODE #define CreateDirectory CreateDirectoryW #else #define CreateDirectory CreateDirectoryA #endif nArray<nString> DirStack; nString AbsPath = DataSrv->ManglePath(Path); while (!DirectoryExists(AbsPath)) { AbsPath.StripTrailingSlash(); int LastSepIdx = AbsPath.GetLastDirSeparatorIndex(); DirStack.PushBack(AbsPath.ExtractRange(LastSepIdx + 1, AbsPath.Length() - (LastSepIdx + 1))); AbsPath = AbsPath.ExtractRange(0, LastSepIdx); } while (DirStack.Size()) { AbsPath += "/" + DirStack.Back(); DirStack.Erase(DirStack.Size() - 1); if (!CreateDirectory(AbsPath.Get(), NULL)) FAIL; } OK; }
//--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { Memo3->Clear(); Image1->Visible=false; Image2->Visible=true; //ADOQuery2->SQL->Text="delete from ErrorReport"; //ADOQuery2->ExecSQL(); //ADOQuery1->ExecSQL(); //ADOConnection1->Connected=false; //ADOConnection1->Connected=true; FunctionQuit=0; Button2->Enabled=false; Button3->Enabled=true; if(!DirectoryExists(Edit1->Text)) { ShowMessage("目录不正确,请检查后重新启动"); return; } scanDir(Edit1->Text); Button3->Enabled=false; Button2->Enabled=true; StatusBar1->SimpleText="文件扫描检查完成!"; Image1->Visible=true; Image2->Visible=false; }
bool vsFile::DeleteDirectory( const vsString &filename ) { if ( DirectoryExists(filename) ) { vsArray<vsString> files; DirectoryContents(&files, filename); for ( int i = 0; i < files.ItemCount(); i++ ) { vsString ff = vsFormatString("%s/%s", filename.c_str(), files[i].c_str()); if ( vsFile::DirectoryExists( ff ) ) { // it's a directory; remove it! DeleteDirectory( ff ); } else { // it's a file, delete it. Delete( ff ); } } // I should now be empty, so delete me. return DeleteEmptyDirectory( filename ); } return false; }
int PrepareHookModule(wchar_t (&szModule)[MAX_PATH+16]) { int iRc = -251; wchar_t szNewPath[MAX_PATH+16] = {}, szAddName[32] = {}, szVer[2] = {}; INT_PTR nLen = 0; // Copy szModule to CSIDL_LOCAL_APPDATA and return new path HRESULT hr = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szNewPath); if ((hr != S_OK) || !*szNewPath) { iRc = -251; goto wrap; } szVer[0] = MVV_4a[0]; _wsprintf(szAddName, SKIPLEN(countof(szAddName)) L"\\ConEmuHk%s.%02u%02u%02u%s.dll", WIN3264TEST(L"",L"64"), MVV_1, MVV_2, MVV_3, szVer); nLen = lstrlen(szNewPath); if (szNewPath[nLen-1] != L'\\') { szNewPath[nLen++] = L'\\'; szNewPath[nLen] = 0; } if ((nLen + lstrlen(szAddName) + 8) >= countof(szNewPath)) { iRc = -252; goto wrap; } wcscat_c(szNewPath, L"ConEmu"); if (!DirectoryExists(szNewPath)) { if (!CreateDirectory(szNewPath, NULL)) { iRc = -253; goto wrap; } } wcscat_c(szNewPath, szAddName); if (FileExists(szNewPath) && FileCompare(szNewPath, szModule)) { // OK, file exists and match the required } else { if (!CopyFile(szModule, szNewPath, FALSE)) { iRc = -254; goto wrap; } } wcscpy_c(szModule, szNewPath); iRc = 0; wrap: return iRc; }
__fastcall TLoggerFile::TLoggerFile(const TPropertyMap &Init) : _outp(0), _max_file_count(Init["MaxFileCount"].ToInt()), _file_name(Init["Name"]) { if(_file_name.IsEmpty()) _file_name = ExtractFilePath(GetModuleName(0))+"log\\"+Now().FormatString("yyyymmdd")+".log"; _path = ExtractFilePath(_file_name); if(!DirectoryExists(_path)) CreateDirectory(_path.c_str(), 0); Reset(); Info(String().sprintf("%s запуск", GetModuleName(0))); }
std::string cXdg::GetHomeVideosDirectory() { const std::string sHome = GetHomeDirectory(); std::string sDirectory = sHome + "/Videos"; if (!DirectoryExists(sDirectory)) sDirectory = GetDirectory("VIDEOS"); return sDirectory; }
bool vsFile::Delete( const vsString &filename ) // static method { if ( DirectoryExists(filename) ) // This file is a directory, don't delete it! return false; return PHYSFS_delete(filename.c_str()) != 0; }
std::string cXdg::GetHomePicturesDirectory() { const std::string sHome = GetHomeDirectory(); std::string sDirectory = sHome + "/Pictures"; if (!DirectoryExists(sDirectory)) sDirectory = GetDirectory("PICTURES"); return sDirectory; }
//--------------------------------------------------------------------------- void __fastcall TRelFolderSelectorForm::ShellTreeViewChange( TObject *Sender, TTreeNode *Node) { if(ShellTreeView->Path != "" && DirectoryExists(ShellTreeView->Path)) OKButton->Enabled = true; else OKButton->Enabled = false; }
std::string cXdg::GetHomeDocumentsDirectory() { const std::string sHome = GetHomeDirectory(); std::string sDirectory = sHome + "/Documents"; if (!DirectoryExists(sDirectory)) sDirectory = GetDirectory("DOCUMENTS"); return sDirectory; }
std::string cXdg::GetHomeMusicDirectory() { const std::string sHome = GetHomeDirectory(); std::string sDirectory = sHome + "/Music"; if (!DirectoryExists(sDirectory)) sDirectory = GetDirectory("MUSIC"); return sDirectory; }
//--------------------------------------------------------------------------- void __fastcall TfrmMacros::SaveMacroses(void) { String Folder=ExtractFilePath(Application->ExeName)+"Macroses"; if (!DirectoryExists(Folder)) CreateDir(Folder); for (int i=0;i<FMacrosList->Count;i++) FMacrosList->Items[i]->SaveToFile(Folder); }
std::string cXdg::GetHomeDownloadsDirectory() { const std::string sHome = GetHomeDirectory(); std::string sDirectory = sHome + "/Downloads"; if (!DirectoryExists(sDirectory)) sDirectory = GetDirectory("DOWNLOAD"); return sDirectory; }