source: dev/trunk/ab5.0/jenga/include/common/Environment.h@ 771

Last change on this file since 771 was 718, checked in by dai, 16 years ago
  • Web設定をオプションダイアログから除去した(不要な機能)。
  • Jenga::Common::Environment::GetUserAppDirメソッドを追加。
  • Jenga::Common::Directoryクラスコンストラクタを修正。
File size: 1.8 KB
Line 
1#pragma once
2
3namespace Jenga{
4namespace Common{
5
6#pragma warning(disable : 4996)
7
8class Environment
9{
10public:
11 static const std::string GetCurrentDir()
12 {
13 char temp[MAX_PATH];
14 ::GetCurrentDirectory( MAX_PATH, temp );
15 return temp;
16 }
17
18 static const std::string &GetAppDir()
19 {
20 static std::string appDir;
21 if( appDir.empty() )
22 {
23 char temporary[MAX_PATH];
24 char temp2[MAX_PATH];
25 char temp3[MAX_PATH];
26 GetModuleFileName(GetModuleHandle(0),temporary,MAX_PATH);
27 _splitpath(temporary,temp2,temp3,NULL,NULL);
28 if( temp3[lstrlen(temp3)-1]=='\\' )
29 {
30 temp3[lstrlen(temp3)-1] = 0;
31 }
32 lstrcat(temp2,temp3);
33
34 appDir = temp2;
35 }
36 return appDir;
37 }
38
39 static const std::string &GetAppFileName()
40 {
41 static std::string appFileName;
42 if( appFileName.empty() )
43 {
44 char temporary[MAX_PATH];
45 char temp2[MAX_PATH];
46 char temp3[MAX_PATH];
47 GetModuleFileName(GetModuleHandle(0),temporary,MAX_PATH);
48 _splitpath(temporary,NULL,NULL,temp2,temp3);
49 lstrcat(temp2,temp3);
50
51 appFileName = temp2;
52 }
53 return appFileName;
54 }
55
56 static const std::string &GetAppFilePath()
57 {
58 static std::string appFilePath;
59 if( appFilePath.empty() )
60 {
61 char temporary[MAX_PATH];
62 GetModuleFileName(GetModuleHandle(0),temporary,MAX_PATH);
63
64 appFilePath = temporary;
65 }
66 return appFilePath;
67 }
68
69 static const std::string &GetUserAppDir()
70 {
71 static std::string userAppDir;
72 if( userAppDir.empty() )
73 {
74 char szDirPath[MAX_PATH];
75 if( SHGetSpecialFolderPath( NULL, szDirPath, CSIDL_APPDATA, TRUE ) == FALSE )
76 {
77 throw;
78 }
79 userAppDir = szDirPath;
80
81 if( userAppDir[userAppDir.size()-1] == '\\' )
82 {
83 userAppDir = userAppDir.substr( 0, userAppDir.size() - 1 );
84 }
85 }
86
87 return userAppDir;
88 }
89};
90
91
92}}
Note: See TracBrowser for help on using the repository browser.