コード例 #1
0
	gcString GetWildcardPath(gcString wildcard)
	{
#ifdef WIN32
		if (Safe::stricmp("PROGRAM_FILES", wildcard.c_str()) == 0)
		{
			wchar_t path[MAX_PATH]  = {0};
			SHGetFolderPathW(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, path);
			return path;
		}
		else if (Safe::stricmp("DOCUMENTS", wildcard.c_str()) == 0)
		{
			return GetSpecialPath(1);
		}
		else if (Safe::stricmp("JAVA_PATH", wildcard.c_str()) == 0)
		{
			std::string cur = UTIL::WIN::getRegValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\CurrentVersion");

			if (cur.size() > 0)
				return UTIL::WIN::getRegValue(gcString("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\{0}\\JavaHome", cur));
		}
		else if (Safe::stricmp("APP_DATA", wildcard.c_str())==0)
		{
			wchar_t path[MAX_PATH]  = {0};
			SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
			return path;
		}
		else if (Safe::stricmp("USER_APP_DATA", wildcard.c_str())==0)
		{
			return GetSpecialPath(2);
		}
#endif
		return "";
	}
コード例 #2
0
ファイル: MetaLauncher.cpp プロジェクト: tmbx/vnc
// setup baseMenuFolder
void MetaLauncher::setBaseMenuFolder()
{
    wchar_t path[MAX_PATH];

	if (m_clientconn->m_opts.m_menuLoc == MENULOC_MIXLOCAL) {
        if (SHGetFolderPathW(NULL, CSIDL_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, path) != S_OK) {
            vnclog.Print(0, _T("Failed to get menu directory.\n"));
            return;
        }
        m_baseMenuFolder = new wchar_t[wcslen(path) + 1];
        wcscpy(m_baseMenuFolder, path);
    } else {
        if (SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, SHGFP_TYPE_CURRENT, path) != S_OK) {
            vnclog.Print(0, _T("Failed to get menu directory.\n"));
            return;
        }
        m_baseMenuFolder = new wchar_t[wcslen(path) + wcslen(topMenuFolder) + wcslen(m_desktopFolderName) + 3];
        wcscpy(m_baseMenuFolder, path);
        wcscat(m_baseMenuFolder, L"\\");
        wcscat(m_baseMenuFolder, topMenuFolder);
        if (CreateDirectoryW(m_baseMenuFolder, NULL) == 0) {
            vnclog.Print(0, _T("Failed to create menu directory. (error %d)\n"), GetLastError());
            return;
        }
        if (m_clientconn->m_opts.m_menuLoc == MENULOC_SEPARATE) {
            wcscat(m_baseMenuFolder, L"\\");
            wcscat(m_baseMenuFolder, m_desktopFolderName);
            if (CreateDirectoryW(m_baseMenuFolder, NULL) == 0) {
                vnclog.Print(0, _T("Failed to create menu directory. (error %d)\n"), GetLastError());
                return;
            }
        }
    }
}
コード例 #3
0
ファイル: main.c プロジェクト: michelangelo13/utox-update
static int uninstall_tox()
{
    if (MessageBox(NULL, "Are you sure you want to uninstall uTox?", "uTox Updater", MB_YESNO | MB_ICONQUESTION | MB_SETFOREGROUND) == IDYES) {
        wchar_t wsz[MAX_PATH + 64];

        if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, 0, wsz))) {
            wcscat(wsz, L"\\Programs\\Tox.lnk");
            DeleteFileW(wsz);
        }

        if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, wsz))) {
            wcscat(wsz, L"\\Tox.lnk");
            DeleteFileW(wsz);
        }

        SHDeleteKey(HKEY_CURRENT_USER, "Software\\Classes\\tox");
        SHDeleteKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\uTox");
        SHDeleteValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", "uTox");
        DeleteFile(TOX_EXE_NAME);
        DeleteFile(TOX_VERSION_FILENAME);
        MessageBox(main_window, "uTox uninstalled.", "uTox Updater", MB_OK | MB_SETFOREGROUND);
    }

    exit(0);
}
コード例 #4
0
ファイル: channel_tcp.c プロジェクト: eswartz/emul
static void ini_ssl(void) {
    static int inited = 0;
    if (inited) return;
    OpenSSL_add_all_algorithms();
    SSL_load_error_strings();
    SSL_library_init();
    while (!RAND_status()) {
        struct timespec ts;
        clock_gettime(CLOCK_REALTIME, &ts);
        RAND_add(&ts.tv_nsec, sizeof(ts.tv_nsec), 0.1);
    }
    inited = 1;
#ifdef WIN32
    {
        WCHAR fnm[MAX_PATH];
        char buf[MAX_PATH];
        static char sbuf[MAX_PATH];
        if (SHGetFolderPathW(0, CSIDL_WINDOWS, NULL, 0, fnm) != S_OK) {
            check_error(set_errno(ERR_OTHER, "Cannot get WINDOWS folder path"));
        }
        if (!WideCharToMultiByte(CP_UTF8, 0, fnm, -1, buf, sizeof(buf), NULL, NULL)) {
            check_error(set_win32_errno(GetLastError()));
        }
        snprintf(sbuf, sizeof(sbuf), "%s/TCF", buf);
        tcf_dir = sbuf;
    }
#endif
}
コード例 #5
0
ファイル: theme.c プロジェクト: AlexSteel/wine
static void update_shell_folder_listview(HWND dialog) {
    int i;
    LVITEMW item;
    LONG lSelected = SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_GETNEXTITEM, -1,
                                        MAKELPARAM(LVNI_SELECTED,0));

    SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_DELETEALLITEMS, 0, 0);

    for (i=0; i<NUM_ELEMS(asfiInfo); i++) {
        WCHAR buffer[MAX_PATH];
        HRESULT hr;
        LPITEMIDLIST pidlCurrent;

        /* Some acrobatic to get the localized name of the shell folder */
        hr = SHGetFolderLocation(dialog, asfiInfo[i].nFolder, NULL, 0, &pidlCurrent);
        if (SUCCEEDED(hr)) { 
            LPSHELLFOLDER psfParent;
            LPCITEMIDLIST pidlLast;
            hr = SHBindToParent(pidlCurrent, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast);
            if (SUCCEEDED(hr)) {
                STRRET strRet;
                hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_FORADDRESSBAR, &strRet);
                if (SUCCEEDED(hr)) {
                    hr = StrRetToBufW(&strRet, pidlLast, buffer, MAX_PATH);
                }
                IShellFolder_Release(psfParent);
            }
            ILFree(pidlCurrent);
        }

        /* If there's a dangling symlink for the current shell folder, SHGetFolderLocation
         * will fail above. We fall back to the (non-verified) path of the shell folder. */
        if (FAILED(hr)) {
            hr = SHGetFolderPathW(dialog, asfiInfo[i].nFolder|CSIDL_FLAG_DONT_VERIFY, NULL,
                                 SHGFP_TYPE_CURRENT, buffer);
        }
    
        item.mask = LVIF_TEXT | LVIF_PARAM;
        item.iItem = i;
        item.iSubItem = 0;
        item.pszText = buffer;
        item.lParam = (LPARAM)&asfiInfo[i];
        SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_INSERTITEMW, 0, (LPARAM)&item);

        item.mask = LVIF_TEXT;
        item.iItem = i;
        item.iSubItem = 1;
        item.pszText = strdupU2W(asfiInfo[i].szLinkTarget);
        SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item);
        HeapFree(GetProcessHeap(), 0, item.pszText);
    }

    /* Ensure that the previously selected item is selected again. */
    if (lSelected >= 0) {
        item.mask = LVIF_STATE;
        item.state = LVIS_SELECTED;
        item.stateMask = LVIS_SELECTED;
        SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_SETITEMSTATE, lSelected, (LPARAM)&item);
    }
}
コード例 #6
0
ファイル: shelldispatch.c プロジェクト: PatroxGaurab/wine
static HRESULT WINAPI FolderItemImpl_get_Path(FolderItem *iface, BSTR *pbs)
{
    FolderItemImpl *This = impl_from_FolderItem(iface);
    HRESULT ret = S_OK;
    WCHAR *pathW;
    int len;

    TRACE("(%p,%p)\n", iface, pbs);

    *pbs = NULL;
    if (V_VT(&This->dir) == VT_I4)
    {
        pathW = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR));
        if (!pathW) return E_OUTOFMEMORY;
        ret = SHGetFolderPathW(NULL, V_I4(&This->dir), NULL, SHGFP_TYPE_CURRENT,
                pathW);
        if (ret == S_OK)
            *pbs = SysAllocString(pathW);
        else if (ret == E_INVALIDARG)
        {
            FIXME("not implemented for %#x\n", V_I4(&This->dir));
            ret = E_NOTIMPL;
        }
        HeapFree(GetProcessHeap(), 0, pathW);
    }
    else /* VT_BSTR */
    {
        pathW = V_BSTR(&This->dir);
        len = lstrlenW(pathW);
        *pbs = SysAllocStringLen(pathW, pathW[len - 1] == '\\' ? len - 1 : len);
    }
    if (ret == S_OK && !*pbs)
        ret = E_OUTOFMEMORY;
    return ret;
}
コード例 #7
0
static BOOL appbundle_init(void)
{
    WCHAR shellDesktopPath[MAX_PATH];

    HRESULT hr = SHGetFolderPathW(NULL, CSIDL_DESKTOP, NULL, SHGFP_TYPE_CURRENT, shellDesktopPath);
    if (SUCCEEDED(hr))
        mac_desktop_dir = wine_get_unix_file_name(shellDesktopPath);

    if (mac_desktop_dir == NULL)
    {
        WINE_ERR("error looking up the desktop directory\n");
        return FALSE;
    }

    if (getenv("WINE_APPLICATIONS_DIR"))
        wine_applications_dir = strdupA(getenv("WINE_APPLICATIONS_DIR"));
    else
        wine_applications_dir = heap_printf("%s/Applications/Wine", getenv("HOME"));
    if (!wine_applications_dir)
        return FALSE;

    create_directories(wine_applications_dir);
    WINE_TRACE("Applications in %s\n", wine_applications_dir);

    return TRUE;
}
コード例 #8
0
ファイル: D3D8CaptureHook.cpp プロジェクト: leohawke/Capture
//Todo Support It
//Don't Support D3D8 Game In Xp And Vista
bool h3d::BeginD3D8CaptureHook() {

	wchar_t sD3D8Path[MAX_PATH];
	SHGetFolderPathW(NULL, CSIDL_SYSTEM, NULL, SHGFP_TYPE_CURRENT, sD3D8Path);
	wcscat_s(sD3D8Path, MAX_PATH, L"\\D3D8.dll");

	HMODULE hD3D8Dll = GetModuleHandle(sD3D8Path);
	if (hD3D8Dll) {
		PTR addr = reinterpret_cast<PTR>(hD3D8Dll);
		PTR end_sceneoffset = 0;

		UINT version = GetOSVersion();

		if (version == 7)
			end_sceneoffset = 0x44530;
		if (version >= 8)
			end_sceneoffset = 0x33540;

		if (end_sceneoffset) {
			d3d8end_scene.Do((WINAPIPROC)(addr + end_sceneoffset), (WINAPIPROC)EndScne);
			return true;
		}
	}

	return false;
}
コード例 #9
0
ファイル: win32.c プロジェクト: zxlooong/libaacs
const char *win32_get_config_system(const char *dir)
{
    static char appdir[PATH_MAX] = "";
    wchar_t wdir[MAX_PATH];

    if (!dir) {
        // first call

        if (*appdir)
            return appdir;

        /* Get the "Application Data" folder for all users */
        if (S_OK == SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE,
                    NULL, SHGFP_TYPE_CURRENT, wdir)) {
            WideCharToMultiByte (CP_UTF8, 0, wdir, -1, appdir, PATH_MAX, NULL, NULL);
            return appdir;
        } else {
            DEBUG(DBG_FILE, "Can't find common configuration directory !\n");
            return NULL;
        }
    } else {
        // next call
        return NULL;
    }

    return dir;
}
コード例 #10
0
ファイル: path-win.c プロジェクト: CrimsonVoid/mpv
char *mp_get_win_config_path(const char *filename)
{
    wchar_t w_appdir[MAX_PATH + 1] = {0};
    wchar_t w_exedir[MAX_PATH + 1] = {0};
    char *res = NULL;
    void *tmp = talloc_new(NULL);

#ifndef __CYGWIN__
    if (SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL,
        SHGFP_TYPE_CURRENT, w_appdir) != S_OK)
        w_appdir[0] = '\0';
#endif

    get_exe_dir(w_exedir);

    if (filename && filename[0] && w_exedir[0]) {
        char *dir = mp_to_utf8(tmp, w_exedir);
        char *temp = mp_path_join(tmp, bstr0(dir), bstr0("mpv"));
        res = mp_path_join(NULL, bstr0(temp), bstr0(filename));
        if (!mp_path_exists(res) || mp_path_isdir(res)) {
            talloc_free(res);
            res = NULL;
        }
    }

    if (!res && w_appdir[0]) {
        char *dir = mp_to_utf8(tmp, w_appdir);
        char *temp = mp_path_join(tmp, bstr0(dir), bstr0("mpv"));
        res = mp_path_join(NULL, bstr0(temp), bstr0(filename));
    }

    talloc_free(tmp);
    return res;
}
コード例 #11
0
ファイル: fileFuncs.cpp プロジェクト: stefson/libutil
/**
 *  Wrapper um SHGetKnownFolderPath, unter Vista und Größer benutzt es das
 *  originale SHGetKnownFolderPath, ansonsten SHGetFolderPath.
 *
 *  @param[in] rfid
 *  @param[in] path
 *
 *  @return liefert den Status zurück (S_OK bei OK)
 *
 *  @author FloSoft
 */
static HRESULT mySHGetKnownFolderPath(REFKNOWNFOLDERID rfid, std::string& path)
{
    HRESULT retval = S_FALSE;
    LPWSTR ppszPath = NULL;

    if(!gShell32DLLInst)
        gShell32DLLInst = LoadLibraryW(L"Shell32.dll");

    if(gShell32DLLInst && !gSHGetKnownFolderPath)
        gSHGetKnownFolderPath = (LPSHGetKnownFolderPath)GetProcAddress(gShell32DLLInst, "SHGetKnownFolderPath");

    if(gSHGetKnownFolderPath)
        retval = gSHGetKnownFolderPath(rfid, KF_FLAG_CREATE, NULL, &ppszPath);
    else if(rfid == FOLDERID_Documents)
    {
        ppszPath = (LPWSTR)CoTaskMemAlloc(MAX_PATH * sizeof(WCHAR));
        if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL, 0, ppszPath)))
            retval = S_OK;
    }

    if(ppszPath)
    {
        LPSTR ppszPathA = UnicodeToAnsi(ppszPath);
        path = ppszPathA;
        CoTaskMemFree(ppszPath);
        delete[] ppszPathA;
    }

    return retval;
}
コード例 #12
0
ファイル: platform_windows.c プロジェクト: EchoLiao/hedgewars
char *__PHYSFS_platformCalcPrefDir(const char *org, const char *app)
{
    /*
     * Vista and later has a new API for this, but SHGetFolderPath works there,
     *  and apparently just wraps the new API. This is the new way to do it:
     *
     *     SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE,
     *                          NULL, &wszPath);
     */

    WCHAR path[MAX_PATH];
    char *utf8 = NULL;
    size_t len = 0;
    char *retval = NULL;

    if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
                                   NULL, 0, path)))
        BAIL_MACRO(PHYSFS_ERR_OS_ERROR, NULL);

    utf8 = unicodeToUtf8Heap(path);
    BAIL_IF_MACRO(!utf8, ERRPASS, NULL);
    len = strlen(utf8) + strlen(org) + strlen(app) + 4;
    retval = allocator.Malloc(len);
    if (!retval)
    {
        allocator.Free(utf8);
        BAIL_MACRO(PHYSFS_ERR_OUT_OF_MEMORY, NULL);
    } /* if */

    sprintf(retval, "%s\\%s\\%s\\", utf8, org, app);
    return retval;
} /* __PHYSFS_platformCalcPrefDir */
コード例 #13
0
ファイル: misc.cpp プロジェクト: bolidehi/qdevelop
//static function to determine the QDevelop directory (used for settings and global ctags database)
// the directory is returnded WITH a trailing slash
QString getQDevelopPath(void)
{
	static QString path;
	if (!path.isEmpty()) return path;
	
	// if we havn't yet done so, determine the full db file name and make sure the directory exists
	// determine path for application data dirs
#ifdef Q_OS_WIN32
	wchar_t buf[MAX_PATH];
	if (!SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, buf))
		path = QString::fromUtf16((ushort *)buf)+"/";
	else
		path = QDir::homePath()+"/Application Data/"; // this shouldn't happen
#else
	path = QDir::homePath()+"/";
#endif

	// create subdir
	QDir dir(path);
#ifdef Q_OS_WIN32
	dir.mkdir("QDevelop");
	path += "QDevelop/";
#else
	dir.mkdir(".qdevelop");
	path += ".qdevelop/";
#endif
	return path;
}
コード例 #14
0
ファイル: gamestatistics.c プロジェクト: miurahr/wine
/*******************************************************************************
 * GAMEUX_buildStatisticsFilePath
 * Creates path to file containing statistics of game with given id.
 *
 * Parameters:
 *  lpApplicationId                         [I]     application id of game,
 *                                                  as string
 *  lpStatisticsFile                        [O]     array where path will be
 *                                                  stored. Its size must be
 *                                                  at least MAX_PATH
 */
static HRESULT GAMEUX_buildStatisticsFilePath(
        LPCWSTR lpApplicationId,
        LPWSTR lpStatisticsFile)
{
    static const WCHAR sBackslash[] = {'\\',0};
    static const WCHAR sStatisticsDir[] = {'\\','M','i','c','r','o','s','o','f','t',
            '\\','W','i','n','d','o','w','s','\\','G','a','m','e','E','x','p',
            'l','o','r','e','r','\\','G','a','m','e','S','t','a','t','i','s',
            't','i','c','s','\\',0};
    static const WCHAR sDotGamestats[] = {'.','g','a','m','e','s','t','a','t','s',0};

    HRESULT hr;

    hr = SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, lpStatisticsFile);

    if(SUCCEEDED(hr))
    {
        lstrcatW(lpStatisticsFile, sStatisticsDir);
        lstrcatW(lpStatisticsFile, lpApplicationId);
        lstrcatW(lpStatisticsFile, sBackslash);
        lstrcatW(lpStatisticsFile, lpApplicationId);
        lstrcatW(lpStatisticsFile, sDotGamestats);
    }

    return hr;
}
コード例 #15
0
ファイル: clearshot.c プロジェクト: rossy/clearshot
static int ShowSaveDialog(wchar_t* name, size_t nameLength)
{
    wchar_t* defaultPath = xmalloc(MAX_PATH * sizeof(wchar_t));

    OPENFILENAMEW ofn = {
        .lStructSize  = sizeof(OPENFILENAMEW),
        .lpstrFilter  = L"PNG image\0*.png\0",
        .nFilterIndex = 1,
        .lpstrFile    = name,
        .nMaxFile     = nameLength,
        .Flags        = OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
    };

    /* This may seem like an archaic way of getting the default pictures
       directory since it doesn't understand Windows 7 libraries, however
       GetSaveFileName will open the library anyway if given CSIDL_MYPICTURES
       and doing it this way is backwards compatible with Windows Vista */
    if (SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, SHGFP_TYPE_CURRENT, defaultPath) == S_OK)
        ofn.lpstrInitialDir = defaultPath;

    if (!GetSaveFileNameW(&ofn))
    {
        free(defaultPath);
        return 0;
    }

    free(defaultPath);
    return 1;
}

static FILE* OpenFileWrite(wchar_t* name)
{
    /* Every Windows program should have a variant of this function to replace
       fopen. That is, one that supports Unicode and FILE_SHARE_DELETE. */
    HANDLE winHandle = CreateFileW(
                           name,
                           GENERIC_READ | GENERIC_WRITE,
                           FILE_SHARE_READ | FILE_SHARE_DELETE,
                           NULL,
                           CREATE_ALWAYS,
                           0, NULL);
    if (!winHandle)
        return NULL;

    int crtHandle = _open_osfhandle((intptr_t)winHandle, 0);
    if (crtHandle == -1)
    {
        CloseHandle(winHandle);
        return NULL;
    }

    FILE* result = _fdopen(crtHandle, "wb");
    if (!result)
    {
        _close(crtHandle);
        return NULL;
    }

    return result;
}
コード例 #16
0
ファイル: dirs.c プロジェクト: RicoP/vlcfork
const char *config_GetConfDir (void)
{
    static char appdir[PATH_MAX] = "";
    wchar_t wdir[MAX_PATH];

#warning FIXME: thread-safety!
    if (*appdir)
        return appdir;

#if defined (UNDER_CE)
    /*There are some errors in cegcc headers*/
#undef SHGetSpecialFolderPath
    BOOL WINAPI SHGetSpecialFolderPath(HWND,LPWSTR,int,BOOL);
    if( SHGetSpecialFolderPath( NULL, wdir, CSIDL_APPDATA, 1 ) )
#else
    /* Get the "Application Data" folder for all users */
    if( S_OK == SHGetFolderPathW( NULL, CSIDL_COMMON_APPDATA
              | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, wdir ) )
#endif
    {
        WideCharToMultiByte (CP_UTF8, 0, wdir, -1,
                             appdir, PATH_MAX, NULL, NULL);
        return appdir;
    }
    return NULL;
}
コード例 #17
0
    //---------------------------------------------------------------------
	void FileSystemLayer::prepareUserHome(const Ogre::String& subdir)
	{
		// fill mHomePath
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
		WCHAR wpath[MAX_PATH];
		if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, 0, wpath)))
			widePathToOgreString(mHomePath, wpath);
#elif OGRE_PLATFORM == OGRE_PLATFORM_WINRT
		widePathToOgreString(mHomePath, Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data());
#endif

		if(!mHomePath.empty())
		{
			// create Ogre subdir
			mHomePath += "\\Ogre\\";
			if (!createDirectory(mHomePath))
			{
				// couldn't create directory, fall back to current working dir
				mHomePath.clear();
			}
			else
			{
				mHomePath += subdir + '\\';
				// create release subdir
				if (!createDirectory(mHomePath))
				{
					// couldn't create directory, fall back to current working dir
					mHomePath.clear();
				}
			}
		}
	}
コード例 #18
0
ファイル: dirs_win32.c プロジェクト: DaveDaCoda/mythtv
char *win32_get_font_dir(const char *font_file)
{
    wchar_t wdir[MAX_PATH];
    if (S_OK != SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir)) {
        int lenght = GetWindowsDirectoryW(wdir, MAX_PATH);
        if (lenght == 0 || lenght > (MAX_PATH - 8)) {
            BD_DEBUG(DBG_FILE, "Font directory path too long!\n");
            return NULL;
        }
        if (!wcscat(wdir, L"\\fonts")) {
            BD_DEBUG(DBG_FILE, "Could not construct font directory path!\n");
            return NULL;
        }

    }

    int   len  = WideCharToMultiByte (CP_UTF8, 0, wdir, -1, NULL, 0, NULL, NULL);
    char *path = malloc(len + strlen(font_file) + 2);
    if (path) {
        WideCharToMultiByte(CP_UTF8, 0, wdir, -1, path, len, NULL, NULL);
        path[len - 1] = '\\';
        strcpy(path + len, font_file);
    }
    return path;
}
コード例 #19
0
QString PathHelper::getLocalDesktopPath()
{
    //
    // !!! QDesktopServices::storageLocation could be used for this as well
    //

    QString localDesktopPath = "";

#ifdef Q_WS_WIN
    // SHGetFolderPathW: (http://msdn.microsoft.com/en-us/library/bb762181(v=vs.85).aspx)
    // minimum windows version: 2000, XP
    WCHAR szPath[MAX_PATH];
    if(SUCCEEDED(SHGetFolderPathW(NULL,
                                 CSIDL_DESKTOP|CSIDL_FLAG_CREATE,
                                 NULL,
                                 0,
                                 szPath)))
    {
        localDesktopPath = QString::fromWCharArray(szPath);
    }

    // SHGetKnownFolderPath: "This function replaces SHGetFolderPath. That older function is now simply a wrapper for SHGetKnownFolderPath."
    // from Windows Vista the desired way is: SHGetKnownFolderPath (http://msdn.microsoft.com/en-us/library/bb762188(v=vs.85).aspx)
    //  BUT SHGetKnownFolderPath requires Vista as minimum OS !!
#endif

#ifdef Q_WS_MAC
    localDesktopPath = "~/Desktop";
#endif

    return localDesktopPath;
}
コード例 #20
0
static CFURLRef _preferencesDirectoryForUserHostSafetyLevel(CFStringRef userName, CFStringRef hostName, unsigned long safeLevel) {
    CFAllocatorRef alloc = __CFPreferencesAllocator();
#if 0

	CFURLRef url = NULL;

	UniChar szPath[MAX_PATH];
	if (S_OK == SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (LPWSTR) szPath)) {
		CFStringRef directoryPath = CFStringCreateWithCharacters(alloc, szPath, strlen_UniChar(szPath));
		if (directoryPath) {
			CFStringRef completePath = CFStringCreateWithFormat(alloc, NULL, CFSTR("%@\\Apple\\"), directoryPath);
			if (completePath) {
				url = CFURLCreateWithFileSystemPath(alloc, completePath, kCFURLWindowsPathStyle, true);
				CFRelease(completePath);
			}
			CFRelease(directoryPath);
		}
	}

	// Can't find a better place?  Home directory then?
	if (url == NULL)
		url = CFCopyHomeDirectoryURLForUser((userName == kCFPreferencesCurrentUser) ? NULL : userName);

	return url;
 
#else
    CFURLRef  home = NULL;
    CFURLRef  url;
    int levels = 0;
    //    if (hostName != kCFPreferencesCurrentHost && hostName != kCFPreferencesAnyHost) return NULL; // Arbitrary host access not permitted
    if (userName == kCFPreferencesAnyUser) {
        if (!home) home = CFURLCreateWithFileSystemPath(alloc, CFSTR("/Library/Preferences/"), kCFURLPOSIXPathStyle, true);
        levels = 1;
        if (hostName == kCFPreferencesCurrentHost) url = home;
        else {
            url = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("Network/"), kCFURLPOSIXPathStyle, true, home);
            levels ++;
            CFRelease(home);
        }
    } else {
        home = CFCopyHomeDirectoryURLForUser((userName == kCFPreferencesCurrentUser) ? NULL : userName);
        if (home) {
            url = (safeLevel > 0) ? CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("Library/Safe Preferences/"), kCFURLPOSIXPathStyle, true, home) :
            CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("Library/Preferences/"), kCFURLPOSIXPathStyle, true, home);
            levels = 2;
            CFRelease(home);
            if (hostName != kCFPreferencesAnyHost) {
                home = url;
                url = CFURLCreateWithFileSystemPathRelativeToBase(alloc, CFSTR("ByHost/"), kCFURLPOSIXPathStyle, true, home);
                levels ++;
                CFRelease(home);
            }
        } else {
            url = NULL;
        }
    }
    return url;
#endif
}
コード例 #21
0
ファイル: system.c プロジェクト: greck2908/qengine
char *Sys_GetHomeDir(void)
{
  char *cur;
  char *old;
  char profile[MAX_PATH];
  int len;
  static char gdir[MAX_OSPATH];
  WCHAR sprofile[MAX_PATH];
  WCHAR uprofile[MAX_PATH];

  /* The following lines implement a horrible
     hack to connect the UTF-16 WinAPI to the
     ASCII Quake II. While this should work in
     most cases, it'll fail if the "Windows to
     DOS filename translation" is switched off.
     In that case the function will return NULL
     and no homedir is used. */

  /* Get the path to "My Documents" directory */
  SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, 0, uprofile);

  /* Create a UTF-16 DOS path */
  len = GetShortPathNameW(uprofile, sprofile, sizeof(sprofile));

  if (len == 0) {
    return NULL;
  }

  /* Since the DOS path contains no UTF-16 characters, just convert it to ASCII
   */
  WideCharToMultiByte(CP_ACP, 0, sprofile, -1, profile, sizeof(profile), NULL, NULL);

  if (len == 0) {
    return NULL;
  }

  /* Check if path is too long */
  if ((len + strlen(CFGDIR) + 3) >= 256) {
    return NULL;
  }

  /* Replace backslashes by slashes */
  cur = old = profile;

  if (strstr(cur, "\\") != NULL) {
    while (cur != NULL) {
      if ((cur - old) > 1) {
        *cur = '/';
      }

      old = cur;
      cur = strchr(old + 1, '\\');
    }
  }

  snprintf(gdir, sizeof(gdir), "%s/%s/", profile, CFGDIR);

  return gdir;
}
コード例 #22
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemCommonAppDataPath ( void )
{
    wchar_t szResult[MAX_PATH] = L"";
    SHGetFolderPathW( NULL, CSIDL_COMMON_APPDATA, NULL, 0, szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
コード例 #23
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemSystemPath ( void )
{
    wchar_t szResult[MAX_PATH] = L"";
    SHGetFolderPathW( NULL, CSIDL_SYSTEM, NULL, 0, szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
コード例 #24
0
ファイル: CFPlatform.c プロジェクト: mlabbe/CoreFoundation
CFURLRef CFCopyHomeDirectoryURL(void) {
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
    uid_t euid;
    __CFGetUGIDs(&euid, NULL);
    struct passwd *upwd = getpwuid(euid ? euid : getuid());
    return _CFCopyHomeDirURLForUser(upwd, true);
#elif DEPLOYMENT_TARGET_WINDOWS
    CFURLRef retVal = NULL;
    CFIndex len = 0;
    CFStringRef str = NULL;
   
    UniChar pathChars[MAX_PATH];
    if (S_OK == SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, (wchar_t *)pathChars)) {
        len = (CFIndex)wcslen((wchar_t *)pathChars);
        str = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, pathChars, len);
        retVal = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str, kCFURLWindowsPathStyle, true);
        CFRelease(str);
    }

    if (!retVal) {
        // Fall back to environment variable, but this will not be unicode compatible
        const char *cpath = __CFgetenv("HOMEPATH");
        const char *cdrive = __CFgetenv("HOMEDRIVE");
        if (cdrive && cpath) {
            char fullPath[CFMaxPathSize];
            strlcpy(fullPath, cdrive, sizeof(fullPath));
            strlcat(fullPath, cpath, sizeof(fullPath));
            str = CFStringCreateWithCString(kCFAllocatorSystemDefault, fullPath, kCFPlatformInterfaceStringEncoding);
            retVal = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, str, kCFURLWindowsPathStyle, true);
            CFRelease(str);
        }
    }

    if (!retVal) {
        // Last resort: We have to get "some" directory location, so fall-back to the processes current directory.
        UniChar currDir[MAX_PATH];
        DWORD dwChars = GetCurrentDirectoryW(MAX_PATH + 1, (wchar_t *)currDir);
        if (dwChars > 0) {
            len = (CFIndex)wcslen((wchar_t *)currDir);
            str = CFStringCreateWithCharacters(kCFAllocatorDefault, currDir, len);
            retVal = CFURLCreateWithFileSystemPath(NULL, str, kCFURLWindowsPathStyle, true);
            CFRelease(str);
        }
    }

    // We could do more here (as in KB Article Q101507). If that article is to be believed, we should only run into this case on Win95, or through user error.
    CFStringRef testPath = CFURLCopyFileSystemPath(retVal, kCFURLWindowsPathStyle);
    if (CFStringGetLength(testPath) == 0) {
        CFRelease(retVal);
        retVal = NULL;
    }
    if (testPath) CFRelease(testPath);

    return retVal;
#else
#error Dont know how to compute users home directories on this platform
#endif
}
コード例 #25
0
std::string
get_application_data_folder() {
  wchar_t szPath[MAX_PATH];

  if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_APPDATA | CSIDL_FLAG_CREATE, nullptr, 0, szPath)))
    return to_utf8(std::wstring(szPath)) + "\\mkvtoolnix";

  return "";
}
コード例 #26
0
ファイル: startmnucust.cpp プロジェクト: Strongc/reactos
VOID OnAdvancedStartMenuItems()
{
    WCHAR szPath[MAX_PATH];

    if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, 0, szPath)))
    {
        ShellExecuteW(NULL, L"explore", szPath, NULL, NULL, SW_SHOWNORMAL);
    }
}
コード例 #27
0
static std::string GetWindowsFolder(int folderId, const char* errorMsg) {
	wchar_t szPath[MAX_PATH];
	szPath[0] = 0;
	if ( !SUCCEEDED( SHGetFolderPathW( NULL, folderId, NULL, 0, szPath ) ) )
	{
		throw std::runtime_error(errorMsg);
	}
	return win32_utf16_to_utf8(szPath);
}
コード例 #28
0
ファイル: winvlc.c プロジェクト: cobr123/qtVlc
static void get_crashdump_path(wchar_t * wdir)
{
    if( S_OK != SHGetFolderPathW( NULL,
                        CSIDL_APPDATA | CSIDL_FLAG_CREATE,
                        NULL, SHGFP_TYPE_CURRENT, wdir ) )
        fprintf( stderr, "Can't open the vlc conf PATH\n" );

    swprintf( wdir+wcslen( wdir ), L"%s", L"\\vlc\\crashdump" );
}
コード例 #29
0
ファイル: dirs.c プロジェクト: Aakash-729/vlc
static char *config_GetShellDir (int csidl)
{
    wchar_t wdir[MAX_PATH];

    if (SHGetFolderPathW (NULL, csidl | CSIDL_FLAG_CREATE,
                          NULL, SHGFP_TYPE_CURRENT, wdir ) == S_OK)
        return FromWide (wdir);
    return NULL;
}
コード例 #30
0
/*
 * Class:     com_lksoft_ia_CommonAppdata
 * Method:    getCommonAppdataDir
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_com_lksoft_ia_CommonAppdata_getCommonAppdataDir
  (JNIEnv *env, jclass c) {

	WCHAR path[MAX_PATH];
	if(SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, 0, path) == S_OK) {
		return (*env)->NewString(env, (jchar *)path, wcslen(path));
	} else {
		return NULL;
	}
}