Home » U++ Library support » U++ Core » Core/Path.cpp: the limitation of GetCurrentDirectory for POSIX
Core/Path.cpp: the limitation of GetCurrentDirectory for POSIX [message #31503] |
Mon, 07 March 2011 12:27 |
|
Hello all,
Looking in the other projects, I see a limitation in U++ of get GetCurrentDirectory for POSIX.
This changes works perfectly for me for more than 1 month. I propose to implement this or to know motivation why this was done?
OK, Now to the source-code in the file Core/Path.cpp:
The old version:
#ifndef PLATFORM_WINCE
String GetCurrentDirectory() {
#if defined(PLATFORM_WIN32)
if(IsWinNT()) {
wchar h[MAX_PATH];
UnicodeWin32().GetCurrentDirectoryW(MAX_PATH, h);
return FromSystemCharsetW(h);
}
else {
char h[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, h);
return FromSystemCharset(h);
}
#elif defined(PLATFORM_POSIX)
char h[1024];
getcwd(h, 1024);
return FromSystemCharset(h);
#else
#error GetCurrentDirectory not implemented for this platform, comment this line to get Null
return Null;
#endif//PLATFORM
}
#endif
and the new version:
#ifndef PLATFORM_WINCE
String GetCurrentDirectory() {
#if defined(PLATFORM_WIN32)
if(IsWinNT()) {
wchar h[MAX_PATH];
UnicodeWin32().GetCurrentDirectoryW(MAX_PATH, h);
return FromSystemCharsetW(h);
}
else {
char h[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, h);
return FromSystemCharset(h);
}
#elif defined(PLATFORM_POSIX)
//ILU: propose another get current directory realization
/*
char h[1024];
getcwd(h, 1024);
return FromSystemCharset(h);
*/
char *h = getcwd(NULL, 0);
String str_final = FromSystemCharset(h);
free(h);
return str_final;
#else
#error GetCurrentDirectory not implemented for this platform, comment this line to get Null
return Null;
#endif//PLATFORM
}
#endif
and a question: why the buffer h was set limited to 1024 chars?
Thank you in advance,
Ion Lupascu.
|
|
|
|
Goto Forum:
Current Time: Thu Apr 25 08:02:48 CEST 2024
Total time taken to generate the page: 0.05140 seconds
|