| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  |  | #include "..\e2dtool.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | #include <algorithm>
 | 
					
						
							|  |  |  |  | #include <commdlg.h>
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | extern "C" const GUID DECLSPEC_SELECTANY FOLDERID_LocalAppData = {  | 
					
						
							|  |  |  |  | 	0xF1B32785, 0x6FBA, 0x4FCF, { 0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91 } | 
					
						
							|  |  |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | e2d::String				e2d::Path::_tempPath; | 
					
						
							|  |  |  |  | e2d::String				e2d::Path::_dataPath; | 
					
						
							|  |  |  |  | std::list<e2d::String>	e2d::Path::_paths; | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | void e2d::Path::setGameFolderName(const String & name) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	if (name.isEmpty()) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>Ĭ<EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							|  |  |  |  | 	String localAppDataPath = Path::getLocalAppDataPath(); | 
					
						
							|  |  |  |  | 	if (!localAppDataPath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 		_dataPath = localAppDataPath + L"\\Easy2DGameData\\" << name << L"\\"; | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 		if (!Path::exists(_dataPath) && !Path::createFolder(_dataPath)) | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 			_dataPath = L""; | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 		_dataPath << L"Data.ini"; | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 	wchar_t path[_MAX_PATH]; | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 	if (0 != ::GetTempPath(_MAX_PATH, path)) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 		_tempPath << path << L"\\Easy2DGameTemp\\" << name << L"\\"; | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 		if (!Path::exists(_tempPath) && !Path::createFolder(_tempPath)) | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 			_tempPath = L""; | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-03 01:52:11 +08:00
										 |  |  |  | void e2d::Path::addSearchPath(String path) | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	path.replace(L"/", L"\\"); | 
					
						
							|  |  |  |  | 	if (path[path.getLength() - 1] != L'\\') | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		path << L"\\"; | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	auto iter = std::find(_paths.cbegin(), _paths.cend(), path); | 
					
						
							|  |  |  |  | 	if (iter == _paths.cend()) | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 		_paths.push_front(path); | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | e2d::String e2d::Path::getTempPath() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	return _tempPath; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | e2d::String e2d::Path::getLocalAppDataPath() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	static String localAppDataPath; | 
					
						
							|  |  |  |  | 	if (localAppDataPath.isEmpty()) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><>ȡ AppData/Local <20>ļ<EFBFBD><C4BC>е<EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							|  |  |  |  | 		typedef HRESULT(WINAPI* pFunSHGetKnownFolderPath)(const GUID& rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		PWSTR pszPath = nullptr; | 
					
						
							|  |  |  |  | 		HMODULE hModule = LoadLibrary(L"shell32.dll"); | 
					
						
							|  |  |  |  | 		pFunSHGetKnownFolderPath SHGetKnownFolderPath = (pFunSHGetKnownFolderPath)GetProcAddress(hModule, "SHGetKnownFolderPath"); | 
					
						
							|  |  |  |  | 		HRESULT hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &pszPath); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		if (SUCCEEDED(hr)) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			localAppDataPath = pszPath; | 
					
						
							|  |  |  |  | 			CoTaskMemFree(pszPath); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return localAppDataPath; | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | e2d::String e2d::Path::getCurrentFilePath() | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	TCHAR szPath[_MAX_PATH] = { 0 }; | 
					
						
							|  |  |  |  | 	if (::GetModuleFileName(nullptr, szPath, _MAX_PATH) != 0) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 		return std::move(String(szPath)); | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 	return std::move(String()); | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-03 01:52:11 +08:00
										 |  |  |  | e2d::String e2d::Path::findFile(const String& path) | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	if (Path::exists(path)) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return path; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 		for (auto& resPath : _paths) | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			if (Path::exists(resPath + path)) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				return resPath + path; | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 	return std::move(String()); | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-27 01:28:01 +08:00
										 |  |  |  | e2d::String e2d::Path::extractResource(int resNameId, const String & resType, const String & destFileName) | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	String destFilePath = _tempPath + destFileName; | 
					
						
							| 
									
										
										
										
											2018-05-27 01:28:01 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
 | 
					
						
							|  |  |  |  | 	HANDLE hFile = ::CreateFile((LPCWSTR)destFilePath, GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL); | 
					
						
							|  |  |  |  | 	if (hFile == INVALID_HANDLE_VALUE) | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 		return std::move(String()); | 
					
						
							| 
									
										
										
										
											2018-05-27 01:28:01 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ļ<EFBFBD><C4BC>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>ڴ桢<DAB4>õ<EFBFBD><C3B5><EFBFBD>Դ<EFBFBD><D4B4>С
 | 
					
						
							|  |  |  |  | 	HRSRC hRes = ::FindResource(NULL, MAKEINTRESOURCE(resNameId), (LPCWSTR)resType); | 
					
						
							|  |  |  |  | 	HGLOBAL hMem = ::LoadResource(NULL, hRes); | 
					
						
							|  |  |  |  | 	DWORD dwSize = ::SizeofResource(NULL, hRes); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-27 01:48:26 +08:00
										 |  |  |  | 	if (hRes && hMem && dwSize) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// д<><D0B4><EFBFBD>ļ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		DWORD dwWrite = 0; | 
					
						
							|  |  |  |  | 		::WriteFile(hFile, hMem, dwSize, &dwWrite, NULL); | 
					
						
							|  |  |  |  | 		::CloseHandle(hFile); | 
					
						
							|  |  |  |  | 		return destFilePath; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		::CloseHandle(hFile); | 
					
						
							|  |  |  |  | 		::DeleteFile((LPCWSTR)destFilePath); | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 		return std::move(String()); | 
					
						
							| 
									
										
										
										
											2018-05-27 01:48:26 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-27 01:28:01 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | e2d::String e2d::Path::getDataPath() | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	return _dataPath; | 
					
						
							| 
									
										
										
										
											2018-02-28 19:46:03 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  |  | e2d::String e2d::Path::getFileExtension(const String& filePath) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	String fileExtension; | 
					
						
							|  |  |  |  | 	// <20>ҵ<EFBFBD><D2B5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB> '.' <20><>λ<EFBFBD><CEBB>
 | 
					
						
							| 
									
										
										
										
											2018-05-03 22:21:01 +08:00
										 |  |  |  | 	size_t pos = filePath.getWString().find_last_of(L'.'); | 
					
						
							|  |  |  |  | 	// <20>ж<EFBFBD> pos <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Чλ<D0A7><CEBB>
 | 
					
						
							|  |  |  |  | 	if (pos != std::wstring::npos) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><>ȡ<EFBFBD><C8A1>չ<EFBFBD><D5B9>
 | 
					
						
							| 
									
										
										
										
											2018-05-03 22:21:01 +08:00
										 |  |  |  | 		fileExtension = filePath.subtract(static_cast<int>(pos)); | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 		// ת<><D7AA>ΪСд<D0A1><D0B4>ĸ
 | 
					
						
							|  |  |  |  | 		fileExtension = fileExtension.toLower(); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return fileExtension; | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  |  | e2d::String e2d::Path::getSaveFilePath(const String& title, const String& defExt) | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
 | 
					
						
							|  |  |  |  | 	OPENFILENAME ofn = { 0 }; | 
					
						
							|  |  |  |  | 	wchar_t strFilename[MAX_PATH] = { 0 };				// <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
 | 
					
						
							|  |  |  |  | 	ofn.lStructSize = sizeof(OPENFILENAME);				// <20>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD>С
 | 
					
						
							| 
									
										
										
										
											2018-07-03 18:16:26 +08:00
										 |  |  |  | 	ofn.hwndOwner = Window::getInstance()->getHWnd();	// <20><><EFBFBD>ھ<EFBFBD><DABE><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	ofn.lpstrFilter = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>\0*.*\0\0";				// <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>
 | 
					
						
							|  |  |  |  | 	ofn.nFilterIndex = 1;								// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	ofn.lpstrFile = strFilename;						// <20><><EFBFBD>շ<EFBFBD><D5B7>ص<EFBFBD><D8B5>ļ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
 | 
					
						
							|  |  |  |  | 	ofn.nMaxFile = sizeof(strFilename);					// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-17 15:22:14 +08:00
										 |  |  |  | 	ofn.lpstrInitialDir = nullptr;						// <20><>ʼĿ¼ΪĬ<CEAA><C4AC>
 | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; | 
					
						
							| 
									
										
										
										
											2018-07-03 18:16:26 +08:00
										 |  |  |  | 	ofn.lpstrTitle = (LPCWSTR)title;					// <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	ofn.lpstrDefExt = (LPCWSTR)defExt;					// Ĭ<><C4AC><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>չ<EFBFBD><D5B9>
 | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (GetSaveFileName(&ofn)) | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 		return strFilename; | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  |  | 	return std::move(String()); | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  |  | bool e2d::Path::createFolder(const String& dirPath) | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 	if (dirPath.isEmpty() || dirPath.getLength() >= MAX_PATH) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return false; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 	wchar_t tmpDirPath[_MAX_PATH] = { 0 }; | 
					
						
							|  |  |  |  | 	int length = dirPath.getLength(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for (int i = 0; i < length; ++i) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 		tmpDirPath[i] = dirPath.at(i); | 
					
						
							|  |  |  |  | 		if (tmpDirPath[i] == L'\\' || tmpDirPath[i] == L'/' || i == (length - 1)) | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 			if (::_waccess(tmpDirPath, 0) != 0) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				if (::_wmkdir(tmpDirPath) != 0) | 
					
						
							|  |  |  |  | 				{ | 
					
						
							|  |  |  |  | 					return false; | 
					
						
							|  |  |  |  | 				} | 
					
						
							|  |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-03-28 17:56:04 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return true; | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | bool e2d::Path::exists(const String & path) | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 	if (path.isEmpty() || path.getLength() >= MAX_PATH) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return false; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return ::_waccess((const wchar_t *)path, 0) == 0; | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | } |