bool LLFilePickerBase::getMultipleLoadFiles(ELoadFilter filter, std::string const& folder) { if( mLocked ) { return FALSE; } bool success = FALSE; llutf16string tstring = utf8str_to_utf16str(folder); mOFN.lpstrInitialDir = (LPCTSTR)tstring.data(); mFilesW[0] = '\0'; mOFN.lpstrFile = mFilesW; mOFN.nFilterIndex = 1; mOFN.nMaxFile = FILENAME_BUFFER_SIZE; mOFN.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_ALLOWMULTISELECT; setupFilter(filter); reset(); // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetOpenFileName(&mOFN); // pauses until ok or cancel. if( success ) { // The getopenfilename api doesn't tell us if we got more than // one file, so we have to test manually by checking string // lengths. if( wcslen(mOFN.lpstrFile) > mOFN.nFileOffset ) /*Flawfinder: ignore*/ { std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); mFiles.push_back(filename); } else { mLocked = TRUE; WCHAR* tptrw = mFilesW; std::string dirname; while(1) { if (*tptrw == 0 && *(tptrw+1) == 0) // double '\0' break; if (*tptrw == 0) tptrw++; // shouldn't happen? std::string filename = utf16str_to_utf8str(llutf16string(tptrw)); if (dirname.empty()) dirname = filename + "\\"; else mFiles.push_back(dirname + filename); tptrw += filename.size(); } } } return success; }
std::string LLDir_Win32::getCurPath() { WCHAR w_str[MAX_PATH]; GetCurrentDirectory(MAX_PATH, w_str); return utf16str_to_utf8str(llutf16string(w_str)); }
bool LLFilePickerBase::getLoadFile(ELoadFilter filter, std::string const& folder) { if( mLocked ) { return FALSE; } bool success = FALSE; llutf16string tstring = utf8str_to_utf16str(folder); mOFN.lpstrInitialDir = (LPCTSTR)tstring.data(); mFilesW[0] = '\0'; mOFN.lpstrFile = mFilesW; mOFN.nMaxFile = SINGLE_FILENAME_BUFFER_SIZE; mOFN.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR ; mOFN.nFilterIndex = 1; setupFilter(filter); reset(); // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetOpenFileName(&mOFN); if (success) { std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); mFiles.push_back(filename); } return success; }
BOOL LLDirPicker::getDir(std::string* filename) { if( mLocked ) { return FALSE; } // if local file browsing is turned off, return without opening dialog if ( check_local_file_access_enabled() == false ) { return FALSE; } BOOL success = FALSE; // Modal, so pause agent send_agent_pause(); BROWSEINFO bi; memset(&bi, 0, sizeof(bi)); bi.ulFlags = BIF_USENEWUI; bi.hwndOwner = (HWND)gViewerWindow->getPlatformWindow(); bi.lpszTitle = NULL; ::OleInitialize(NULL); LPITEMIDLIST pIDL = ::SHBrowseForFolder(&bi); if(pIDL != NULL) { WCHAR buffer[_MAX_PATH] = {'\0'}; if(::SHGetPathFromIDList(pIDL, buffer) != 0) { // Set the string value. mDir = utf16str_to_utf8str(llutf16string(buffer)); success = TRUE; } // free the item id list CoTaskMemFree(pIDL); } ::OleUninitialize(); send_agent_resume(); // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); return success; }
BOOL LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking) { if( mLocked ) { return FALSE; } BOOL success = FALSE; // if local file browsing is turned off, return without opening dialog if ( check_local_file_access_enabled() == false ) { return FALSE; } // don't provide default file selection mFilesW[0] = '\0'; mOFN.hwndOwner = (HWND)gViewerWindow->getPlatformWindow(); mOFN.lpstrFile = mFilesW; mOFN.nMaxFile = SINGLE_FILENAME_BUFFER_SIZE; mOFN.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR ; mOFN.nFilterIndex = 1; setupFilter(filter); if (blocking) { // Modal, so pause agent send_agent_pause(); } reset(); // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetOpenFileName(&mOFN); if (success) { std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); mFiles.push_back(filename); } if (blocking) { send_agent_resume(); // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); } return success; }
// get a random file in the directory // automatically wrap if we've hit the end void LLDir_Win32::getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) { S32 num_files; S32 which_file; HANDLE random_search_h; fname = ""; llutf16string pathname = utf8str_to_utf16str(dirname); pathname += utf8str_to_utf16str(mask); WIN32_FIND_DATA FileData; fname[0] = NULL; num_files = countFilesInDir(dirname,mask); if (!num_files) { return; } which_file = ll_rand(num_files); // llinfos << "Random select mp3 #" << which_file << llendl; // which_file now indicates the (zero-based) index to which file to play if ((random_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE) { while (which_file--) { if (!FindNextFile(random_search_h, &FileData)) { return; } } FindClose(random_search_h); fname = utf16str_to_utf8str(llutf16string(FileData.cFileName)); } }
// For reasons of convenience, handle IME updates here. // This largely mirrors the old implementation, only sans the carbon parameters. void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigned int *replacementRange, long text_len, attributedStringInfo segments) { if (gWindowImplementation->getPreeditor()) { LLPreeditor *preeditor = gWindowImplementation->getPreeditor(); preeditor->resetPreedit(); // This should be a viable replacement for the kEventParamTextInputSendReplaceRange parameter. if (replacementRange[0] < replacementRange[1]) { const LLWString& text = preeditor->getPreeditString(); const S32 location = wstring_wstring_length_from_utf16_length(text, 0, replacementRange[0]); const S32 length = wstring_wstring_length_from_utf16_length(text, location, replacementRange[1]); preeditor->markAsPreedit(location, length); } LLWString fix_str = utf16str_to_wstring(llutf16string(unitext, text_len)); S32 caret_position = fix_str.length(); preeditor->updatePreedit(fix_str, segments.seg_lengths, segments.seg_standouts, caret_position); } }
LLDir_Win32::LLDir_Win32() { mDirDelimiter = "\\"; WCHAR w_str[MAX_PATH]; // Application Data is where user settings go SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE); mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); // We want cache files to go on the local disk, even if the // user is on a network with a "roaming profile". // // On XP this is: // C:\Docments and Settings\James\Local Settings\Application Data // On Vista this is: // C:\Users\James\AppData\Local // // We used to store the cache in AppData\Roaming, and the installer // cleans up that version on upgrade. JC if(HMODULE shell = LoadLibrary(L"shell32")) //SHGetSpecialFolderPath is deprecated from Vista an onwards. Try to use SHGetSpecialFolderPath if it's available { HRESULT (WINAPI* pSHGetKnownFolderPath)(REFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); pSHGetKnownFolderPath = (HRESULT (WINAPI *)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *))GetProcAddress(shell, "SHGetKnownFolderPath"); WCHAR* pPath = NULL; if(pSHGetKnownFolderPath && (*pSHGetKnownFolderPath)(FOLDERID_LocalAppData, 0, NULL, &pPath) == S_OK) wcscpy_s(w_str,pPath); else SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); FreeLibrary(shell); if(pPath) CoTaskMemFree(pPath); } else //XP doesn't support SHGetKnownFolderPath { SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); } mOSCacheDir = utf16str_to_utf8str(llutf16string(w_str)); if (GetTempPath(MAX_PATH, w_str)) { if (wcslen(w_str)) /* Flawfinder: ignore */ { w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash } mTempDir = utf16str_to_utf8str(llutf16string(w_str)); } else { mTempDir = mOSUserDir; } // fprintf(stderr, "mTempDir = <%s>",mTempDir); // Set working directory, for LLDir::getWorkingDir() GetCurrentDirectory(MAX_PATH, w_str); mWorkingDir = utf16str_to_utf8str(llutf16string(w_str)); // Set the executable directory S32 size = GetModuleFileName(NULL, w_str, MAX_PATH); if (size) { w_str[size] = '\0'; mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str)); S32 path_end = mExecutablePathAndName.find_last_of('\\'); if (path_end != std::string::npos) { mExecutableDir = mExecutablePathAndName.substr(0, path_end); mExecutableFilename = mExecutablePathAndName.substr(path_end+1, std::string::npos); } else { mExecutableFilename = mExecutablePathAndName; } } else { fprintf(stderr, "Couldn't get APP path, assuming current directory!\n"); mExecutableDir = mWorkingDir; // Assume it's the current directory } // mAppRODataDir = "."; // Determine the location of the App-Read-Only-Data // Try the working directory then the exe's dir. mAppRODataDir = mWorkingDir; // if (mExecutableDir.find("indra") == std::string::npos) // *NOTE:Mani - It is a mistake to put viewer specific code in // the LLDir implementation. The references to 'skins' and // 'llplugin' need to go somewhere else. // alas... this also gets called during static initialization // time due to the construction of gDirUtil in lldir.cpp. if(! LLFile::isdir(mAppRODataDir + mDirDelimiter + "skins")) { // What? No skins in the working dir? // Try the executable's directory. mAppRODataDir = mExecutableDir; } llinfos << "mAppRODataDir = " << mAppRODataDir << llendl; mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins"; // Build the default cache directory mDefaultCacheDir = buildSLOSCacheDir(); // Make sure it exists int res = LLFile::mkdir(mDefaultCacheDir); if (res == -1) { if (errno != EEXIST) { llwarns << "Couldn't create LL_PATH_CACHE dir " << mDefaultCacheDir << llendl; } } mLLPluginDir = mExecutableDir + mDirDelimiter + "llplugin"; }
BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) { if( mLocked ) { return FALSE; } BOOL success = FALSE; mOFN.lpstrFile = mFilesW; if (!filename.empty()) { llutf16string tstring = utf8str_to_utf16str(filename); wcsncpy(mFilesW, tstring.c_str(), FILENAME_BUFFER_SIZE); } /*Flawfinder: ignore*/ else { mFilesW[0] = '\0'; } mOFN.hwndOwner = (HWND)gViewerWindow->getPlatformWindow(); switch( filter ) { case FFSAVE_ALL: mOFN.lpstrDefExt = NULL; mOFN.lpstrFilter = L"All Files (*.*)\0*.*\0" \ L"WAV Sounds (*.wav)\0*.wav\0" \ L"Targa, Bitmap Images (*.tga; *.bmp)\0*.tga;*.bmp\0" \ L"\0"; break; case FFSAVE_WAV: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.wav", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"wav"; mOFN.lpstrFilter = L"WAV Sounds (*.wav)\0*.wav\0" \ L"\0"; break; case FFSAVE_TGA: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.tga", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"tga"; mOFN.lpstrFilter = L"Targa Images (*.tga)\0*.tga\0" \ L"\0"; break; case FFSAVE_BMP: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.bmp", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"bmp"; mOFN.lpstrFilter = L"Bitmap Images (*.bmp)\0*.bmp\0" \ L"\0"; break; case FFSAVE_PNG: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.png", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"png"; mOFN.lpstrFilter = L"PNG Images (*.png)\0*.png\0" \ L"\0"; break; case FFSAVE_JPEG: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.jpeg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"jpeg"; mOFN.lpstrFilter = L"JPEG Images (*.jpeg)\0*.jpeg\0" \ L"\0"; break; case FFSAVE_AVI: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.avi", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"avi"; mOFN.lpstrFilter = L"AVI Movie File (*.avi)\0*.avi\0" \ L"\0"; break; case FFSAVE_ANIM: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.xaf", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"xaf"; mOFN.lpstrFilter = L"XAF Anim File (*.xaf)\0*.xaf\0" \ L"\0"; break; #ifdef _CORY_TESTING case FFSAVE_GEOMETRY: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.slg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"slg"; mOFN.lpstrFilter = L"SLG SL Geometry File (*.slg)\0*.slg\0" \ L"\0"; break; #endif case FFSAVE_XML: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.xml", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"xml"; mOFN.lpstrFilter = L"XML File (*.xml)\0*.xml\0" \ L"\0"; break; case FFSAVE_COLLADA: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.collada", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"collada"; mOFN.lpstrFilter = L"COLLADA File (*.collada)\0*.collada\0" \ L"\0"; break; case FFSAVE_RAW: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.raw", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"raw"; mOFN.lpstrFilter = RAW_FILTER \ L"\0"; break; case FFSAVE_J2C: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.j2c", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"j2c"; mOFN.lpstrFilter = L"Compressed Images (*.j2c)\0*.j2c\0" \ L"\0"; break; default: return FALSE; } mOFN.nMaxFile = SINGLE_FILENAME_BUFFER_SIZE; mOFN.Flags = OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; reset(); // Modal, so pause agent send_agent_pause(); { // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetSaveFileName(&mOFN); if (success) { std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); mFiles.push_back(filename); } gKeyboard->resetKeys(); } send_agent_resume(); // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); return success; }
BOOL LLFilePicker::getMultipleOpenFiles(ELoadFilter filter) { if( mLocked ) { return FALSE; } BOOL success = FALSE; // don't provide default file selection mFilesW[0] = '\0'; mOFN.hwndOwner = (HWND)gViewerWindow->getPlatformWindow(); mOFN.lpstrFile = mFilesW; mOFN.nFilterIndex = 1; mOFN.nMaxFile = FILENAME_BUFFER_SIZE; mOFN.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_ALLOWMULTISELECT; setupFilter(filter); reset(); // Modal, so pause agent send_agent_pause(); // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetOpenFileName(&mOFN); // pauses until ok or cancel. if( success ) { // The getopenfilename api doesn't tell us if we got more than // one file, so we have to test manually by checking string // lengths. if( wcslen(mOFN.lpstrFile) > mOFN.nFileOffset ) /*Flawfinder: ignore*/ { std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); mFiles.push_back(filename); } else { mLocked = TRUE; WCHAR* tptrw = mFilesW; std::string dirname; while(1) { if (*tptrw == 0 && *(tptrw+1) == 0) // double '\0' break; if (*tptrw == 0) tptrw++; // shouldn't happen? std::string filename = utf16str_to_utf8str(llutf16string(tptrw)); if (dirname.empty()) dirname = filename + "\\"; else mFiles.push_back(dirname + filename); tptrw += filename.size(); } } } send_agent_resume(); // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); return success; }
BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) { if( mLocked ) { return FALSE; } BOOL success = FALSE; mOFN.lpstrFile = mFilesW; if (!filename.empty()) { llutf16string tstring = utf8str_to_utf16str(filename); wcsncpy(mFilesW, tstring.c_str(), FILENAME_BUFFER_SIZE); } /*Flawfinder: ignore*/ else { mFilesW[0] = '\0'; } mOFN.hwndOwner = (HWND)gViewerWindow->getPlatformWindow(); switch( filter ) { case FFSAVE_ALL: mOFN.lpstrDefExt = NULL; mOFN.lpstrFilter = L"All Files (*.*)\0*.*\0" \ L"WAV Sounds (*.wav)\0*.wav\0" \ L"Targa, Bitmap Images (*.tga; *.bmp)\0*.tga;*.bmp\0" \ L"\0"; break; case FFSAVE_WAV: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.wav", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"wav"; mOFN.lpstrFilter = L"WAV Sounds (*.wav)\0*.wav\0" \ L"\0"; break; case FFSAVE_TGA: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.tga", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"tga"; mOFN.lpstrFilter = L"Targa Images (*.tga)\0*.tga\0" \ L"\0"; break; case FFSAVE_BMP: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.bmp", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"bmp"; mOFN.lpstrFilter = L"Bitmap Images (*.bmp)\0*.bmp\0" \ L"\0"; break; case FFSAVE_PNG: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.png", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"png"; mOFN.lpstrFilter = L"PNG Images (*.png)\0*.png\0" \ L"\0"; break; case FFSAVE_JPEG: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.jpeg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"jpg"; mOFN.lpstrFilter = L"JPEG Images (*.jpg *.jpeg)\0*.jpg;*.jpeg\0" \ L"\0"; break; case FFSAVE_AVI: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.avi", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"avi"; mOFN.lpstrFilter = L"AVI Movie File (*.avi)\0*.avi\0" \ L"\0"; break; case FFSAVE_ANIM: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.bvh", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"bvh"; mOFN.lpstrFilter = L"Anim File (*.bvh)\0*.bvh\0" \ L"\0"; break; #ifdef _CORY_TESTING case FFSAVE_GEOMETRY: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.slg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"slg"; mOFN.lpstrFilter = L"SLG SL Geometry File (*.slg)\0*.slg\0" \ L"\0"; break; #endif case FFSAVE_XML: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.xml", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"xml"; mOFN.lpstrFilter = L"XML File (*.xml)\0*.xml\0" \ L"\0"; break; case FFSAVE_COLLADA: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.collada", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"collada"; mOFN.lpstrFilter = L"COLLADA File (*.collada)\0*.collada\0" \ L"\0"; break; case FFSAVE_RAW: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.raw", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } mOFN.lpstrDefExt = L"raw"; mOFN.lpstrFilter = RAW_FILTER \ L"\0"; break; case FFSAVE_J2C: if (filename.empty()) { wcsncpy( mFilesW,L"untitled.j2c", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"j2c"; mOFN.lpstrFilter = L"Compressed Images (*.j2c)\0*.j2c\0" \ L"\0"; break; // <edit> case FFSAVE_ANIMATN: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.animatn", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"animatn"; mOFN.lpstrFilter = L"SL Animations (*.animatn)\0*.animatn\0" \ L"\0"; break; case FFSAVE_OGG: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.ogg", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"ogg"; mOFN.lpstrFilter = L"Ogg (*.ogg)\0*.ogg\0" \ L"\0"; break; case FFSAVE_NOTECARD: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.notecard", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"notecard"; mOFN.lpstrFilter = L"Notecards (*.notecard)\0*.notecard\0" \ L"\0"; break; case FFSAVE_GESTURE: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.gesture", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"gesture"; mOFN.lpstrFilter = L"Gestures (*.gesture)\0*.gesture\0" \ L"\0"; break; case FFSAVE_LSL: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.lsl", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"lsl"; mOFN.lpstrFilter = L"LSL (*.lsl)\0*.lsl\0" \ L"Text files (*.txt)\0*.txt\0" L"RTF Files (*.rtf)\0*.rtf\0" L"\0"; break; case FFSAVE_SHAPE: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.shape", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"shape"; mOFN.lpstrFilter = L"Shapes (*.shape)\0*.shape\0" \ L"\0"; break; case FFSAVE_SKIN: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.skin", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"skin"; mOFN.lpstrFilter = L"Skins (*.skin)\0*.skin\0" \ L"\0"; break; case FFSAVE_HAIR: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.hair", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"hair"; mOFN.lpstrFilter = L"Hair (*.hair)\0*.hair\0" \ L"\0"; break; case FFSAVE_EYES: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.eyes", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"eyes"; mOFN.lpstrFilter = L"Eyes (*.eyes)\0*.eyes\0" \ L"\0"; break; case FFSAVE_SHIRT: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.shirt", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"shirt"; mOFN.lpstrFilter = L"Shirts (*.shirt)\0*.shirt\0" \ L"\0"; break; case FFSAVE_PANTS: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.pants", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"pants"; mOFN.lpstrFilter = L"Pants (*.pants)\0*.pants\0" \ L"\0"; break; case FFSAVE_SHOES: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.shoes", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"shoes"; mOFN.lpstrFilter = L"Shoes (*.shoes)\0*.shoes\0" \ L"\0"; break; case FFSAVE_SOCKS: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.socks", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"socks"; mOFN.lpstrFilter = L"Socks (*.socks)\0*.socks\0" \ L"\0"; break; case FFSAVE_JACKET: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.jacket", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"jacket"; mOFN.lpstrFilter = L"Jackets (*.jacket)\0*.jacket\0" \ L"\0"; break; case FFSAVE_GLOVES: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.gloves", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"gloves"; mOFN.lpstrFilter = L"Gloves (*.gloves)\0*.gloves\0" \ L"\0"; break; case FFSAVE_UNDERSHIRT: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.undershirt", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"undershirt"; mOFN.lpstrFilter = L"Undershirts (*.undershirt)\0*.undershirt\0" \ L"\0"; break; case FFSAVE_UNDERPANTS: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.underpants", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"underpants"; mOFN.lpstrFilter = L"Underpants (*.underpants)\0*.underpants\0" \ L"\0"; break; case FFSAVE_SKIRT: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.skirt", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"skirt"; mOFN.lpstrFilter = L"Skirts (*.skirt)\0*.skirt\0" \ L"\0"; break; case FFSAVE_LANDMARK: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.landmark", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"landmark"; mOFN.lpstrFilter = L"Landmarks (*.landmark)\0*.landmark\0" \ L"\0"; break; case FFSAVE_AO: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.ao", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L"ao"; mOFN.lpstrFilter = L"Animation overrides (*.ao)\0*.ao\0" \ L"\0"; break; case FFSAVE_INVGZ: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.inv", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L".inv"; mOFN.lpstrFilter = L"InvCache (*.inv)\0*.inv\0" \ L"\0"; break; case FFSAVE_BLACKLIST: if(filename.empty()) { wcsncpy( mFilesW,L"untitled.blacklist", FILENAME_BUFFER_SIZE); } mOFN.lpstrDefExt = L".blacklist"; mOFN.lpstrFilter = L"Asset Blacklists (*.blacklist)\0*.blacklist\0" \ L"\0"; break; // </edit> default: return FALSE; } mOFN.nMaxFile = SINGLE_FILENAME_BUFFER_SIZE; mOFN.Flags = OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; reset(); // Modal, so pause agent send_agent_pause(); { // NOTA BENE: hitting the file dialog triggers a window focus event, destroying the selection manager!! success = GetSaveFileName(&mOFN); if (success) { std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); mFiles.push_back(filename); } gKeyboard->resetKeys(); } send_agent_resume(); // Account for the fact that the app has been stalled. LLFrameTimer::updateFrameTime(); return success; }
LLDir_Win32::LLDir_Win32() { mDirDelimiter = "\\"; WCHAR w_str[MAX_PATH]; WCHAR* pPath = NULL; if(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &pPath) == S_OK) wcscpy_s(w_str, pPath); CoTaskMemFree(pPath); pPath = NULL; mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); // We want cache files to go on the local disk, even if the // user is on a network with a "roaming profile". // // On Vista and above this is: // C:\Users\<USERNAME>\AppData\Local // // We used to store the cache in AppData\Roaming, and the installer // cleans up that version on upgrade. JC if(SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &pPath) == S_OK) wcscpy_s(w_str, pPath); CoTaskMemFree(pPath); pPath = NULL; mOSCacheDir = utf16str_to_utf8str(llutf16string(w_str)); if (GetTempPath(MAX_PATH, w_str)) { if (wcslen(w_str)) /* Flawfinder: ignore */ { w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash } mTempDir = utf16str_to_utf8str(llutf16string(w_str)); } else { mTempDir = mOSUserDir; } // fprintf(stderr, "mTempDir = <%s>",mTempDir); // Set working directory, for LLDir::getWorkingDir() GetCurrentDirectory(MAX_PATH, w_str); mWorkingDir = utf16str_to_utf8str(llutf16string(w_str)); // Set the executable directory S32 size = GetModuleFileName(NULL, w_str, MAX_PATH); if (size) { w_str[size] = '\0'; mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str)); size_t path_end = mExecutablePathAndName.find_last_of('\\'); if (path_end != std::string::npos) { mExecutableDir = mExecutablePathAndName.substr(0, path_end); mExecutableFilename = mExecutablePathAndName.substr(path_end+1, std::string::npos); } else { mExecutableFilename = mExecutablePathAndName; } } else { fprintf(stderr, "Couldn't get APP path, assuming current directory!\n"); mExecutableDir = mWorkingDir; // Assume it's the current directory } // mAppRODataDir = "."; // Determine the location of the App-Read-Only-Data // Try the working directory then the exe's dir. mAppRODataDir = mWorkingDir; // if (mExecutableDir.find("indra") == std::string::npos) // *NOTE:Mani - It is a mistake to put viewer specific code in // the LLDir implementation. The references to 'skins' and // 'llplugin' need to go somewhere else. // alas... this also gets called during static initialization // time due to the construction of gDirUtil in lldir.cpp. if(! LLFile::isdir(mAppRODataDir + mDirDelimiter + "skins")) { // What? No skins in the working dir? // Try the executable's directory. mAppRODataDir = mExecutableDir; } // LL_INFOS() << "mAppRODataDir = " << mAppRODataDir << LL_ENDL; mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins"; // Build the default cache directory mDefaultCacheDir = buildSLOSCacheDir(); // Make sure it exists int res = LLFile::mkdir(mDefaultCacheDir); if (res == -1) { if (errno != EEXIST) { LL_WARNS() << "Couldn't create LL_PATH_CACHE dir " << mDefaultCacheDir << LL_ENDL; } } mLLPluginDir = mExecutableDir + mDirDelimiter + "llplugin"; }
LLDir_Win32::LLDir_Win32() { mDirDelimiter = "\\"; WCHAR w_str[MAX_PATH]; // Application Data is where user settings go SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE); mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); // We want cache files to go on the local disk, even if the // user is on a network with a "roaming profile". // // On XP this is: // C:\Docments and Settings\James\Local Settings\Application Data // On Vista this is: // C:\Users\James\AppData\Local // // We used to store the cache in AppData\Roaming, and the installer // cleans up that version on upgrade. JC SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); mOSCacheDir = utf16str_to_utf8str(llutf16string(w_str)); if (GetTempPath(MAX_PATH, w_str)) { if (wcslen(w_str)) /* Flawfinder: ignore */ { w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash } mTempDir = utf16str_to_utf8str(llutf16string(w_str)); } else { mTempDir = mOSUserDir; } // fprintf(stderr, "mTempDir = <%s>",mTempDir); #if 1 // Don't use the real app path for now, as we'll have to add parsing to detect if // we're in a developer tree, which has a different structure from the installed product. S32 size = GetModuleFileName(NULL, w_str, MAX_PATH); if (size) { w_str[size] = '\0'; mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str)); S32 path_end = mExecutablePathAndName.find_last_of('\\'); if (path_end != std::string::npos) { mExecutableDir = mExecutablePathAndName.substr(0, path_end); mExecutableFilename = mExecutablePathAndName.substr(path_end+1, std::string::npos); } else { mExecutableFilename = mExecutablePathAndName; } GetCurrentDirectory(MAX_PATH, w_str); mWorkingDir = utf16str_to_utf8str(llutf16string(w_str)); } else { fprintf(stderr, "Couldn't get APP path, assuming current directory!"); GetCurrentDirectory(MAX_PATH, w_str); mExecutableDir = utf16str_to_utf8str(llutf16string(w_str)); // Assume it's the current directory } #else GetCurrentDirectory(MAX_PATH, w_str); mExecutableDir = utf16str_to_utf8str(llutf16string(w_str)); #endif // When running in a dev tree, app_settings is under indra/newview/ // but in production it is under Program Files/meta7/ // Attempt to detect which one we're using. JC if (mExecutableDir.find("indra") != std::string::npos) mAppRODataDir = getCurPath(); else mAppRODataDir = mExecutableDir; // Build the default cache directory mDefaultCacheDir = buildSLOSCacheDir(); // Make sure it exists int res = LLFile::mkdir(mDefaultCacheDir); if (res == -1) { if (errno != EEXIST) { llwarns << "Couldn't create LL_PATH_CACHE dir " << mDefaultCacheDir << llendl; } } }
LLDir_Win32::LLDir_Win32() { mDirDelimiter = "\\"; WCHAR w_str[MAX_PATH]; // Application Data is where user settings go SHGetSpecialFolderPath(NULL, w_str, CSIDL_APPDATA, TRUE); mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); // Local Settings\Application Data is where cache files should // go, they don't get copied to the server if the user moves his // profile around on the network. JC // // TODO: patch the installer to remove old cache files on update, then // enable this code. //SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); //mOSUserCacheDir = utf16str_to_utf8str(llutf16string(w_str)); if (GetTempPath(MAX_PATH, w_str)) { if (wcslen(w_str)) /* Flawfinder: ignore */ { w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash } mTempDir = utf16str_to_utf8str(llutf16string(w_str)); } else { mTempDir = mOSUserDir; } // fprintf(stderr, "mTempDir = <%s>",mTempDir); #if 1 // Don't use the real app path for now, as we'll have to add parsing to detect if // we're in a developer tree, which has a different structure from the installed product. S32 size = GetModuleFileName(NULL, w_str, MAX_PATH); if (size) { w_str[size] = '\0'; mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str)); S32 path_end = mExecutablePathAndName.find_last_of('\\'); if (path_end != std::string::npos) { mExecutableDir = mExecutablePathAndName.substr(0, path_end); mExecutableFilename = mExecutablePathAndName.substr(path_end+1, std::string::npos); } else { mExecutableFilename = mExecutablePathAndName; } GetCurrentDirectory(MAX_PATH, w_str); mWorkingDir = utf16str_to_utf8str(llutf16string(w_str)); } else { fprintf(stderr, "Couldn't get APP path, assuming current directory!"); GetCurrentDirectory(MAX_PATH, w_str); mExecutableDir = utf16str_to_utf8str(llutf16string(w_str)); // Assume it's the current directory } #else GetCurrentDirectory(MAX_PATH, w_str); mExecutableDir = utf16str_to_utf8str(llutf16string(w_str)); #endif // When running in a dev tree, app_settings is under indra/newview/ // but in production it is under Program Files/SecondLife/ // Attempt to detect which one we're using. JC if (mExecutableDir.find("indra") != std::string::npos) mAppRODataDir = getCurPath(); else mAppRODataDir = mExecutableDir; }