Subversion Repositories spk

Rev

Rev 309 | Rev 324 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 309 Rev 319
Line 3... Line 3...
3
#include "WString.h"
3
#include "WString.h"
4
#include "WStringList.h"
4
#include "WStringList.h"
5
#include "../File_IO.h"
5
#include "../File_IO.h"
6
#include "../DirIO.h"
6
#include "../DirIO.h"
7
 
7
 
-
 
8
#ifdef _WIN32
-
 
9
#include <windows.h>
-
 
10
#include <direct.h>
-
 
11
#include <shlobj.h>
-
 
12
#else
-
 
13
#include <dirent.h> 
-
 
14
#include <sys/types.h> 
-
 
15
#include <sys/param.h> 
-
 
16
#include <sys/stat.h> 
-
 
17
#include <unistd.h> 
-
 
18
#endif
-
 
19
 
8
namespace Utils
20
namespace Utils
9
{
21
{
10
	class CommandLine
22
	class CommandLine
11
	{
23
	{
12
	private:
24
	private:
13
		std::shared_ptr<CFileIO> _file;
25
		std::shared_ptr<CFileIO> _file;
14
		Utils::WStringList _options;
26
		Utils::WStringList		_options;
-
 
27
		CDirIO 					_myDoc;
-
 
28
		CDirIO 					_tempDir;
15
		std::vector<Utils::WString> _args;
29
		std::vector<Utils::WString> _args;
-
 
30
		CPackages				_p;
16
 
31
 
17
	public:
32
	public:
18
		CommandLine(int argc, char* argv[])
33
		CommandLine(int argc, char* argv[])
19
		{
34
		{
20
			_file = std::make_shared<CFileIO>(argv[0]);
35
			_file = std::make_shared<CFileIO>(argv[0]);
Line 49... Line 64...
49
#endif
64
#endif
50
				if (d.empty())
65
				if (d.empty())
51
					d = L"./";
66
					d = L"./";
52
				_file->setDir(d);
67
				_file->setDir(d);
53
			}
68
			}
-
 
69
 
-
 
70
			Utils::WString myDoc = L".";
-
 
71
#ifdef _WIN32
-
 
72
			TCHAR pszPath[MAX_PATH];
-
 
73
			if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
-
 
74
			{
-
 
75
				myDoc = pszPath;
-
 
76
			}
-
 
77
#endif
-
 
78
			_myDoc.setDir(myDoc);
-
 
79
			_tempDir.setDir(L".");
-
 
80
 
-
 
81
#ifdef _WIN32
-
 
82
			TCHAR szPath[MAX_PATH + 1];
-
 
83
			DWORD result = GetTempPath(MAX_PATH + 1, szPath);
-
 
84
			if (result > 0)
-
 
85
				_tempDir.setDir(szPath);
-
 
86
#endif
-
 
87
 
-
 
88
			_p.startup(L".", _tempDir.dir(), _myDoc.dir());
54
		}
89
		}
55
 
90
 
56
		const std::shared_ptr<CFileIO> file() const
91
		const std::shared_ptr<CFileIO> file() const
57
		{
92
		{
58
			return _file;
93
			return _file;
Line 66... Line 101...
66
		const Utils::WString& cmdDir() const
101
		const Utils::WString& cmdDir() const
67
		{
102
		{
68
			return _file->dir();
103
			return _file->dir();
69
		}
104
		}
70
 
105
 
-
 
106
		const Utils::WString& tempDir() const
-
 
107
		{
-
 
108
			return _tempDir.dir();
-
 
109
		}
-
 
110
 
-
 
111
		const Utils::WString& myDoc() const
-
 
112
		{
-
 
113
			return _myDoc.dir();
-
 
114
		}
-
 
115
 
71
		const Utils::WStringList options() const
116
		const Utils::WStringList options() const
72
		{
117
		{
73
			return _options;
118
			return _options;
74
		}
119
		}
75
 
120
 
Line 99... Line 144...
99
		{
144
		{
100
			if (_options.contains(s))
145
			if (_options.contains(s))
101
				return _options[s]->data;
146
				return _options[s]->data;
102
			return Utils::WString::Null();
147
			return Utils::WString::Null();
103
		}
148
		}
-
 
149
 
-
 
150
		const CPackages& packages() const
-
 
151
		{
-
 
152
			return _p;
-
 
153
		}
-
 
154
 
-
 
155
		const CDirIO& dirIO() const
-
 
156
		{
-
 
157
			return _file->dirIO();
-
 
158
		}
104
	};
159
	};
105
}
160
}
106
161