[164] | 1 | #pragma once
|
---|
| 2 | #pragma warning(disable : 4996)
|
---|
| 3 |
|
---|
| 4 | #include <vector>
|
---|
| 5 | #include <string>
|
---|
| 6 |
|
---|
| 7 | #include <stdlib.h>
|
---|
| 8 |
|
---|
| 9 | #include <windows.h>
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | namespace Jenga{
|
---|
| 13 | namespace Common{
|
---|
| 14 |
|
---|
| 15 |
|
---|
| 16 | class Environment
|
---|
| 17 | {
|
---|
| 18 | public:
|
---|
[480] | 19 | static const std::string GetCurrentDir()
|
---|
| 20 | {
|
---|
| 21 | char temp[MAX_PATH];
|
---|
| 22 | ::GetCurrentDirectory( MAX_PATH, temp );
|
---|
| 23 | return temp;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
[164] | 26 | static const std::string &GetAppDir()
|
---|
| 27 | {
|
---|
| 28 | static std::string appDir;
|
---|
| 29 | if( appDir.size() == 0 )
|
---|
| 30 | {
|
---|
| 31 | char temporary[MAX_PATH];
|
---|
| 32 | char temp2[MAX_PATH];
|
---|
| 33 | char temp3[MAX_PATH];
|
---|
| 34 | GetModuleFileName(GetModuleHandle(0),temporary,MAX_PATH);
|
---|
| 35 | _splitpath(temporary,temp2,temp3,NULL,NULL);
|
---|
| 36 | if( temp3[lstrlen(temp3)-1]=='\\' )
|
---|
| 37 | {
|
---|
| 38 | temp3[lstrlen(temp3)-1] = 0;
|
---|
| 39 | }
|
---|
| 40 | lstrcat(temp2,temp3);
|
---|
| 41 |
|
---|
| 42 | appDir = temp2;
|
---|
| 43 | }
|
---|
| 44 | return appDir;
|
---|
| 45 | }
|
---|
[477] | 46 |
|
---|
| 47 | static const std::string &GetAppFileName()
|
---|
| 48 | {
|
---|
| 49 | static std::string appFileName;
|
---|
| 50 | if( appFileName.size() == 0 )
|
---|
| 51 | {
|
---|
| 52 | char temporary[MAX_PATH];
|
---|
| 53 | char temp2[MAX_PATH];
|
---|
| 54 | char temp3[MAX_PATH];
|
---|
| 55 | GetModuleFileName(GetModuleHandle(0),temporary,MAX_PATH);
|
---|
| 56 | _splitpath(temporary,NULL,NULL,temp2,temp3);
|
---|
| 57 | lstrcat(temp2,temp3);
|
---|
| 58 |
|
---|
| 59 | appFileName = temp2;
|
---|
| 60 | }
|
---|
| 61 | return appFileName;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | static const std::string &GetAppFilePath()
|
---|
| 65 | {
|
---|
| 66 | static std::string appFilePath;
|
---|
| 67 | if( appFilePath.size() == 0 )
|
---|
| 68 | {
|
---|
| 69 | char temporary[MAX_PATH];
|
---|
| 70 | GetModuleFileName(GetModuleHandle(0),temporary,MAX_PATH);
|
---|
| 71 |
|
---|
| 72 | appFilePath = temporary;
|
---|
| 73 | }
|
---|
| 74 | return appFilePath;
|
---|
| 75 | }
|
---|
[164] | 76 | };
|
---|
| 77 |
|
---|
| 78 |
|
---|
[205] | 79 | }}
|
---|