| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  |  | #include "..\e2dtool.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-02 14:03:04 +08:00
										 |  |  |  | #include <shlobj.h>
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | e2d::String e2d::Path::getDataPath() | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 	static String dataPath; | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | 	if (dataPath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵı<DDB5><C4B1><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | 		String localAppDataPath = Path::getLocalAppDataPath(); | 
					
						
							| 
									
										
										
										
											2018-08-28 00:06:10 +08:00
										 |  |  |  | 		String title = Window::getInstance()->getTitle(); | 
					
						
							| 
									
										
										
										
											2018-08-19 15:11:20 +08:00
										 |  |  |  | 		String folderName = String::parse(title.hash()); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | 		if (!localAppDataPath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-08-19 15:11:20 +08:00
										 |  |  |  | 			dataPath = localAppDataPath + L"\\Easy2DGameData\\" << folderName << L"\\"; | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 			File file(dataPath); | 
					
						
							|  |  |  |  | 			if (!file.exists() && !File::createFolder(dataPath)) | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 				dataPath = L""; | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 		dataPath << L"Data.ini"; | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 	return dataPath; | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | e2d::String e2d::Path::getTempPath() | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 	static String tempPath; | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | 	if (tempPath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							|  |  |  |  | 		wchar_t path[_MAX_PATH]; | 
					
						
							| 
									
										
										
										
											2018-08-28 00:06:10 +08:00
										 |  |  |  | 		String title = Window::getInstance()->getTitle(); | 
					
						
							| 
									
										
										
										
											2018-08-19 15:11:20 +08:00
										 |  |  |  | 		String folderName = String::parse(title.hash()); | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-19 15:11:20 +08:00
										 |  |  |  | 		if (0 != ::GetTempPath(_MAX_PATH, path)) | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-08-19 15:11:20 +08:00
										 |  |  |  | 			tempPath << path << L"\\Easy2DGameTemp\\" << folderName << L"\\"; | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 			File file(tempPath); | 
					
						
							|  |  |  |  | 			if (!file.exists() && !File::createFolder(tempPath)) | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 				tempPath = L""; | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 	return tempPath; | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | e2d::String e2d::Path::getLocalAppDataPath() | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	static String localAppDataPath; | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | 	if (localAppDataPath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><>ȡ AppData/Local <20>ļ<EFBFBD><C4BC>е<EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							| 
									
										
										
										
											2018-09-02 14:03:04 +08:00
										 |  |  |  | 		WCHAR strPath[MAX_PATH] = { 0 }; | 
					
						
							|  |  |  |  | 		::SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, strPath); | 
					
						
							|  |  |  |  | 		localAppDataPath = strPath; | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return localAppDataPath; | 
					
						
							| 
									
										
										
										
											2018-04-26 21:47:56 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | e2d::String e2d::Path::getCurrentFilePath() | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 	static String currFilePath; | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  |  | 	if (currFilePath.isEmpty()) | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 		TCHAR szPath[_MAX_PATH] = { 0 }; | 
					
						
							|  |  |  |  | 		if (::GetModuleFileName(nullptr, szPath, _MAX_PATH) != 0) | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 			currFilePath = szPath; | 
					
						
							| 
									
										
										
										
											2018-05-24 15:47:38 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-08 02:41:44 +08:00
										 |  |  |  | 	return currFilePath; | 
					
						
							| 
									
										
										
										
											2018-05-24 14:33:16 +08:00
										 |  |  |  | } |