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

Last change on this file since 518 was 480, checked in by dai_9181, 17 years ago

構成管理を大幅に改良。

File size: 1.5 KB
Line 
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
12namespace Jenga{
13namespace Common{
14
15
16class Environment
17{
18public:
19 static const std::string GetCurrentDir()
20 {
21 char temp[MAX_PATH];
22 ::GetCurrentDirectory( MAX_PATH, temp );
23 return temp;
24 }
25
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 }
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 }
76};
77
78
79}}
Note: See TracBrowser for help on using the repository browser.