Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
69c63ba2
Commit
69c63ba2
authored
Oct 12, 2009
by
Sebastian Eichelbaum
Browse files
[STYLE]
parent
56a41bb0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
28 deletions
+34
-28
src/kernel/WKernel.cpp
src/kernel/WKernel.cpp
+34
-28
No files found.
src/kernel/WKernel.cpp
View file @
69c63ba2
...
...
@@ -22,23 +22,25 @@
//
//---------------------------------------------------------------------------
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#endif
#include <iostream>
#include <sstream>
#include <list>
#include <string>
#include <vector>
#include <boost/thread/xtime.hpp>
#include <boost/lexical_cast.hpp>
#include "WKernel.h"
#include "WModule.h"
#include "../modules/navigationSlices/WNavigationSliceModule.h"
#include "../common/WException.h"
#include "../graphicsEngine/WGraphicsEngine.h"
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#endif
#include "WKernel.h"
/**
* Used for program wide access to the kernel.
...
...
@@ -213,12 +215,13 @@ bool WKernel::findAppPath()
// Catch some errors
if
(
length
<
0
)
{
fprintf
(
stderr
,
"Error resolving symlink /proc/self/exe.
\n
"
);
WLogger
::
getLogger
()
->
addLogMessage
(
"Error resolving symlink /proc/self/exe.
"
,
"Kernel"
,
LL_ERROR
);
return
false
;
}
if
(
length
>=
255
)
{
fprintf
(
stderr
,
"Path too long. Truncated.
\n
"
);
// TODO(schurade): replace with logger code
WLogger
::
getLogger
()
->
addLogMessage
(
"Path too long. Truncated."
,
"Kernel"
,
LL_ERROR
);
return
false
;
}
...
...
@@ -230,7 +233,7 @@ bool WKernel::findAppPath()
{
appPath
[
length
]
=
'\0'
;
--
length
;
assert
(
length
>=
0
);
assert
(
length
>=
0
);
}
m_AppPath
=
appPath
;
...
...
@@ -239,31 +242,33 @@ bool WKernel::findAppPath()
m_shaderPath
=
shaderPath
+
"shaders/"
;
return
true
;
#elif defined(__APPLE__)
#elif defined(
__APPLE__
)
char
path
[
1024
];
uint32_t
size
=
sizeof
(
path
);
if
(
_NSGetExecutablePath
(
path
,
&
size
)
==
0
)
uint32_t
size
=
sizeof
(
path
);
if
(
_NSGetExecutablePath
(
path
,
&
size
)
==
0
)
{
fprintf
(
stderr
,
"Executable path is %s
\n
"
,
path
);
int
i
=
strlen
(
path
);
while
(
path
[
i
]
!=
'/'
)
{
path
[
i
]
=
'\0'
;
i
--
;
assert
(
i
>=
0
);
}
fprintf
(
stderr
,
"Application path is %s
\n
"
,
path
);
m_AppPath
=
path
;
std
::
string
shaderPath
(
path
);
m_shaderPath
=
shaderPath
+
"shaders/"
;
return
true
;
WLogger
::
getLogger
()
->
addLogMessage
(
"Executable path is "
+
std
::
string
(
path
),
"Kernel"
,
LL_ERROR
);
int
i
=
strlen
(
path
);
while
(
path
[
i
]
!=
'/'
)
{
path
[
i
]
=
'\0'
;
i
--
;
assert
(
i
>=
0
);
}
WLogger
::
getLogger
()
->
addLogMessage
(
"Application path is "
+
std
::
string
(
path
),
"Kernel"
,
LL_ERROR
);
m_AppPath
=
path
;
std
::
string
shaderPath
(
path
);
m_shaderPath
=
shaderPath
+
"shaders/"
;
return
true
;
}
else
{
fprintf
(
stderr
,
"buffer too small; need size %u
\n
"
,
size
);
assert
(
size
<=
sizeof
(
path
));
WLogger
::
getLogger
()
->
addLogMessage
(
"Buffer too small; need size "
+
boost
::
lexical_cast
<
std
::
string
>
(
size
),
"Kernel"
,
LL_ERROR
);
assert
(
size
<=
sizeof
(
path
)
);
}
#else
#error findAppPath not implemented for this platform
...
...
@@ -296,3 +301,4 @@ std::string WKernel::getShaderPath()
{
return
m_shaderPath
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment