/* =========== QE_SaveProject TTimo: whenever QE_SaveProject is called, prefs are updated and saved with the path to the project =========== */ qboolean QE_SaveProject( const char* filename ){ Sys_Printf( "Save project file '%s'\n", filename ); xmlNodePtr node; xmlDocPtr doc = xmlNewDoc( (xmlChar *)"1.0" ); // create DTD node xmlCreateIntSubset( doc, (xmlChar *)"project", NULL, (xmlChar *)"project.dtd" ); // create project node doc->children->next = xmlNewDocNode( doc, NULL, (xmlChar *)"project", NULL ); for ( epair_t* epair = g_qeglobals.d_project_entity->epairs; epair != NULL; epair = epair->next ) { node = xmlNewChild( doc->children->next, NULL, (xmlChar *)"key", NULL ); xmlSetProp( node, (xmlChar*)"name", (xmlChar*)epair->key ); xmlSetProp( node, (xmlChar*)"value", (xmlChar*)epair->value ); } CreateDirectoryPath( filename ); if ( xmlSaveFormatFile( filename, doc, 1 ) != -1 ) { xmlFreeDoc( doc ); Sys_Printf( "Setting current project in prefs to \"%s\"\n", filename ); g_PrefsDlg.m_strLastProject = filename; g_PrefsDlg.SavePrefs(); return TRUE; } else { xmlFreeDoc( doc ); Sys_FPrintf( SYS_ERR, "failed to save project file: \"%s\"\n", filename ); return FALSE; } }
BOOL WINAPI CreateGroupW(LPCWSTR lpGroupName, BOOL bCommonGroup) { WCHAR szGroupPath[MAX_PATH]; DPRINT1("CreateGroupW() called\n"); if (lpGroupName == NULL || *lpGroupName == 0) return TRUE; if (!GetProgramsPath(bCommonGroup, szGroupPath)) { DPRINT1("GetProgramsPath() failed\n"); return FALSE; } DPRINT1("Programs path: '%S'\n", szGroupPath); wcscat(szGroupPath, L"\\"); wcscat(szGroupPath, lpGroupName); DPRINT1("Group path: '%S'\n", szGroupPath); /* Create directory path */ if (!CreateDirectoryPath (szGroupPath, NULL)) return FALSE; /* FIXME: Notify the shell */ DPRINT1("CreateGroupW() done\n"); return TRUE; }
bool __cdecl SetupDirs(LPVOID pParam) { CString sDir, sSrc, sDst; if (g_bIsWindowsNT) { HANDLE hLog = 0; // theLog("Creating %s directory ", (LPCTSTR)g_sInstallRootDir); // CreateDirectoryPath(g_sInstallRootDir); // theLog("and granting everyone read access to it.\n"); // if (! GrantPermissions(g_sInstallRootDir, "everyone", "read", FALSE, hLog)) { // Appropriate message // theLog("Warning: Fail to grant everyone read access to %s (Error %ld).\n", // (LPCTSTR)g_sInstallRootDir, GetLastError()); // } if (! g_sVarTexmf.IsEmpty()) { // theLog("Creating %s directory ", (LPCTSTR)g_sVarTexmf); CreateDirectoryPath(g_sVarTexmf); // theLog("and granting everyone full access to it.\n"); if (! GrantPermissions(g_sVarTexmf, "everyone", "full", FALSE, hLog)) { // Appropriate message // theLog("Warning: Fail to grand everyone full access to %s (Error %ld).\n", // (LPCTSTR)g_sVarTexmf, GetLastError()); } } } // First run : copy all configuration files. for (int i = 0; i < sizeof(g_confFiles)/sizeof(g_confFiles[0]); i += 2) { sSrc = ConcatPath(g_sTexmfMain, g_confFiles[i]); sDst = ConcatPath(g_sVarTexmf, g_confFiles[i+1]); if (FileExists(sSrc) && ! FileExists(sDst)){ SafeCopyFile(sSrc, sDst, TRUE); } } return true; }
void Directory::Create (/*[in]*/ const PathName & path) { CreateDirectoryPath (path.Get()); }
BOOL WINAPI AddDesktopItemW(BOOL bCommonDesktop, LPCWSTR lpItemName, LPCWSTR lpArguments, LPCWSTR lpIconLocation, INT iIcon, LPCWSTR lpWorkingDirectory, /* Optional */ WORD wHotKey, INT iShowCmd) { DYN_FUNCS Ole32; WCHAR szLinkPath[MAX_PATH]; WCHAR szArguments[MAX_PATH]; WCHAR szCommand[MAX_PATH]; WIN32_FIND_DATAW FindData; HANDLE hFind; LPWSTR Ptr; DWORD dwLength; IShellLinkW* psl; IPersistFile* ppf; HRESULT hr; BOOL bResult; DPRINT("AddDesktopItemW() called\n"); bResult = FALSE; if (!GetDesktopPath(bCommonDesktop, szLinkPath)) { DPRINT1("GetDesktopPath() failed\n"); return FALSE; } DPRINT("Desktop path: '%S'\n", szLinkPath); /* Make sure the path exists */ hFind = FindFirstFileW(szLinkPath, &FindData); if (hFind == INVALID_HANDLE_VALUE) { DPRINT("'%S' does not exist\n", szLinkPath); /* Create directory path */ if (!CreateDirectoryPath(szLinkPath, NULL)) return FALSE; } else { DPRINT("'%S' exists\n", szLinkPath); FindClose(hFind); } /* Append backslash, item name and ".lnk" extension */ wcscat(szLinkPath, L"\\"); wcscat(szLinkPath, lpItemName); wcscat(szLinkPath, L".lnk"); DPRINT("Link path: '%S'\n", szLinkPath); /* Split 'lpArguments' string into command and arguments */ Ptr = wcschr(lpArguments, L' '); DPRINT("Ptr %p lpArguments %p\n", Ptr, lpArguments); if (Ptr != NULL) { dwLength = (DWORD)(Ptr - lpArguments); DPRINT("dwLength %lu\n", dwLength); memcpy(szCommand, lpArguments, dwLength * sizeof(WCHAR)); szCommand[dwLength] = 0; Ptr++; wcscpy(szArguments, Ptr); } else { wcscpy(szCommand, lpArguments); szArguments[0] = 0; } DPRINT("szCommand: '%S'\n", szCommand); DPRINT("szArguments: '%S'\n", szArguments); /* Dynamically load ole32.dll */ if (!LoadDynamicImports(&DynOle32, &Ole32)) { DPRINT1("USERENV: Unable to load OLE32.DLL\n"); return FALSE; } Ole32.fn.CoInitialize(NULL); hr = Ole32.fn.CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID*)&psl); if (!SUCCEEDED(hr)) { Ole32.fn.CoUninitialize(); UnloadDynamicImports(&Ole32); return FALSE; } hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf); if (SUCCEEDED(hr)) { psl->lpVtbl->SetDescription(psl, lpItemName); psl->lpVtbl->SetPath(psl, szCommand); psl->lpVtbl->SetArguments(psl, szArguments); psl->lpVtbl->SetIconLocation(psl, lpIconLocation, iIcon); if (lpWorkingDirectory != NULL) { psl->lpVtbl->SetWorkingDirectory(psl, lpWorkingDirectory); } else { psl->lpVtbl->SetWorkingDirectory(psl, L"%HOMEDRIVE%%HOMEPATH%"); } psl->lpVtbl->SetHotkey(psl, wHotKey); psl->lpVtbl->SetShowCmd(psl, iShowCmd); hr = ppf->lpVtbl->Save(ppf, szLinkPath, TRUE); if (SUCCEEDED(hr)) bResult = TRUE; ppf->lpVtbl->Release(ppf); } psl->lpVtbl->Release(psl); Ole32.fn.CoUninitialize(); UnloadDynamicImports(&Ole32); DPRINT("AddDesktopItemW() done\n"); return bResult; }
void EnsurePathWritable(std::string path){ int finalSlash = path.find_last_of('/'); std::string finalPath = path.substr(0, finalSlash); if (DirectoryExists(finalPath)) return; CreateDirectoryPath(finalPath.c_str()); }