annotate trunk/src/dil/Settings.d @ 505:3bb94ba21490

Refactored a great amount of code. Changed many declaration types from Token* to Identifier*. Fix in parseStructInitializer(): append null to idents in else body. Fixed class Parameter and parseParameterList().
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 12 Dec 2007 02:25:42 +0100
parents 325714d8aa6c
children 6160ab7b1816
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
1 /++
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
2 Author: Aziz Köksal
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
3 License: GPL3
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
4 +/
326
4a7359b88c11 - Added package 'dil' to module declarations.
aziz
parents: 325
diff changeset
5 module dil.Settings;
327
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
6 import dil.Messages;
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
7 import dil.Parser, dil.SyntaxTree, dil.Declarations, dil.Expressions;
358
0faf57d99c1c - Replaced calls to std.file.read() with dil.loadFile().
aziz
parents: 349
diff changeset
8 import dil.File;
428
3751db263679 Looking for config.d and language file in executables folder now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 399
diff changeset
9 import tango.io.FilePath;
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 368
diff changeset
10 import common;
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
11
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
12 struct GlobalSettings
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
13 {
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
14 static:
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 368
diff changeset
15 string language; /// Language of loaded messages catalogue.
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
16 string[] messages; /// Table of localized compiler messages.
367
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
17 string[] importPaths; /// Array of import paths to look for modules.
445
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
18 void load()
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
19 {
445
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
20 scope execPath = new FilePath(GetExecutableFilePath());
428
3751db263679 Looking for config.d and language file in executables folder now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 399
diff changeset
21 auto fileName = execPath.file("config.d").toUtf8();
358
0faf57d99c1c - Replaced calls to std.file.read() with dil.loadFile().
aziz
parents: 349
diff changeset
22 auto sourceText = loadFile(fileName);
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
23 auto parser = new Parser(sourceText, fileName);
368
2adf808343d6 - Renamed method start() to init() in Parser.
aziz
parents: 367
diff changeset
24 auto root = parser.start();
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
25
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
26 if (parser.errors.length || parser.lx.errors.length)
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
27 {
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
28 throw new Exception("There are errors in " ~ fileName ~ ".");
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
29 }
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
30
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
31 foreach (decl; root.children)
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
32 {
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
33 auto v = Cast!(VariableDeclaration)(decl);
367
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
34 if (v is null)
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
35 continue;
505
3bb94ba21490 Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 464
diff changeset
36 auto vname = v.idents[0].str;
367
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
37 if (vname == "langfile")
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
38 {
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
39 auto e = v.values[0];
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
40 if (!e)
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
41 throw new Exception("langfile variable has no value set.");
399
ff1d11c27061 Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 394
diff changeset
42 auto val = Cast!(StringExpression)(e);
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
43 if (val)
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
44 // Set fileName to d-file with messages table.
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
45 fileName = val.getString();
367
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
46 }
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
47 else if (vname == "import_paths")
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
48 {
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
49 auto e = v.values[0];
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
50 if (e is null)
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
51 throw new Exception("import_paths variable has no variable set.");
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
52 if (auto array = Cast!(ArrayInitializer)(e))
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
53 {
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
54 foreach (value; array.values)
399
ff1d11c27061 Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 394
diff changeset
55 if (auto str = Cast!(StringExpression)(value))
367
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
56 GlobalSettings.importPaths ~= str.getString();
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
57 }
367
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
58 else
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 358
diff changeset
59 throw new Exception("import_paths variable is set to "~e.classinfo.name~" instead of an ArrayInitializer.");
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
60 }
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
61 }
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
62
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
63 // Load messages
428
3751db263679 Looking for config.d and language file in executables folder now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 399
diff changeset
64 sourceText = loadFile(execPath.file(fileName).toUtf8());
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
65 parser = new Parser(sourceText, fileName);
368
2adf808343d6 - Renamed method start() to init() in Parser.
aziz
parents: 367
diff changeset
66 root = parser.start();
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
67
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
68 if (parser.errors.length || parser.lx.errors.length)
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
69 {
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
70 throw new Exception("There are errors in "~fileName~".");
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
71 }
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
72
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
73 char[][] messages;
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
74 foreach (decl; root.children)
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
75 {
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
76 auto v = Cast!(VariableDeclaration)(decl);
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
77 if (v is null)
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
78 continue;
505
3bb94ba21490 Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 464
diff changeset
79 if (v.idents[0].str == "messages")
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
80 {
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
81 auto e = v.values[0];
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
82 if (!e)
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
83 throw new Exception("messages variable in "~fileName~" has no value set.");
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
84 if (auto array = Cast!(ArrayInitializer)(e))
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
85 {
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
86 foreach (value; array.values)
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
87 {
399
ff1d11c27061 Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 394
diff changeset
88 if (auto str = Cast!(StringExpression)(value))
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
89 messages ~= str.getString();
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
90 }
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
91 }
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
92 else
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
93 throw new Exception("messages variable is set to "~e.classinfo.name~" instead of an ArrayInitializer.");
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
94 }
505
3bb94ba21490 Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 464
diff changeset
95 else if(v.idents[0].str == "lang_code")
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
96 {
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
97 auto e = v.values[0];
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
98 if (!e)
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
99 throw new Exception("lang_code variable in "~fileName~" has no value set.");
399
ff1d11c27061 Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 394
diff changeset
100 if (auto str = Cast!(StringExpression)(e))
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
101 GlobalSettings.language = str.getString();
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
102 }
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
103 }
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
104 if (messages.length != MID.max+1)
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 368
diff changeset
105 throw new Exception(Format("messages table in {0} must exactly have {1} entries, but {2} were found.", fileName, MID.max+1, messages.length));
349
a0711c57c1db - Added variable 'lang_code' to language files.
aziz
parents: 343
diff changeset
106 GlobalSettings.messages = messages;
394
6440da4adb07 Fixed forward references of enum MID complaints by compiler.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
107 dil.Messages.SetMessages(messages);
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
108 }
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents:
diff changeset
109 }
445
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
110
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
111 version(Windows)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
112 {
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
113 private extern(Windows) uint GetModuleFileNameA(void*, char*, uint);
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
114 /++
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
115 Get the fully qualified path to this executable.
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
116 +/
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
117 char[] GetExecutableFilePath()
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
118 {
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
119 alias GetModuleFileNameA GetModuleFileName;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
120 char[] buffer = new char[256];
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
121 uint count;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
122
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
123 while (1)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
124 {
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
125 if (buffer is null)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
126 return null;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
127
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
128 count = GetModuleFileName(null, buffer.ptr, buffer.length);
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
129 if (count == 0)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
130 return null;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
131 if (buffer.length != count && buffer[count] == 0)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
132 break;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
133 // Increase size of buffer
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
134 buffer.length = buffer.length * 2;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
135 }
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
136 assert(buffer[count] == 0);
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
137 // Reduce buffer to the actual length of the string (excluding '\0'.)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
138 if (count < buffer.length)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
139 buffer.length = count;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
140 return buffer;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
141 }
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
142 }
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
143 else version(linux)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
144 {
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
145 private extern(C) size_t readlink(char* path, char* buf, size_t bufsize);
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
146 /++
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
147 Get the fully qualified path to this executable.
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
148 +/
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
149 char[] GetExecutableFilePath()
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
150 {
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
151 char[] buffer = new char[256];
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
152 size_t count;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
153
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
154 while (1)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
155 {
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
156 // This won't work on very old Linux systems.
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
157 count = readlink("/proc/self/exe".ptr, buffer.ptr, buffer.length);
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
158 if (count == -1)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
159 return null;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
160 if (count < buffer.length)
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
161 break;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
162 buffer.length = buffer.length * 2;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
163 }
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
164 buffer.length = count;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
165 return buffer;
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
166 }
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
167 }
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
168 else
294353fe2514 Added functions for finding the executables path.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 428
diff changeset
169 static assert(0, "GetExecutableFilePath() is not implemented on your platform.");