paths-windows.cpp 1.7 KB
Newer Older
1 2
/*
 * paths-windows.cpp
Ronan's avatar
Ronan committed
3
 * Copyright (C) 2010-2018 Belledonne Communications SARL
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

20 21 22
#include <algorithm>
#include <comutil.h>
#include <ShlObj_core.h>
23

Ronan's avatar
Ronan committed
24 25 26
#pragma comment(lib, "comsuppw.lib")
#pragma comment(lib, "kernel32.lib")

27 28
#include "core/platform-helpers/platform-helpers.h"

29 30 31 32
#include "paths-windows.h"

// =============================================================================

33 34
using namespace std;

35 36
LINPHONE_BEGIN_NAMESPACE

37 38 39 40 41 42 43 44
static string getPath (const GUID &id) {
	string strPath;

	LPWSTR path;
	if (SHGetKnownFolderPath(id, KF_FLAG_DONT_VERIFY, 0, &path) == S_OK) {
		strPath = _bstr_t(path);
		replace(strPath.begin(), strPath.end(), '\\', '/');
		CoTaskMemFree(path);
45 46
	}

47
	return strPath.append("/linphone/");
48 49 50 51 52 53
}


string SysPaths::getDataPath (PlatformHelpers *) {
	static string dataPath = getPath(FOLDERID_LocalAppData);
	return dataPath;
54 55
}

56 57 58
string SysPaths::getConfigPath (PlatformHelpers *platformHelpers) {
	// Yes, same path.
	return getDataPath(platformHelpers);
59 60 61
}

LINPHONE_END_NAMESPACE