10#if !defined (HPP_ALIB_CAMP_DIRECTORY)
13#if !defined (HPP_ALIB_CAMP_PROCESSINFO)
16#if !defined (HPP_ALIB_CAMP_ENVIRONMENT)
22#elif defined(__GLIBCXX__) || defined(__APPLE__) || defined(__ANDROID_NDK__)
28 #pragma message ("Unknown Platform in file: " __FILE__ )
31#if !defined (HPP_ALIB_COMPATIBILITY_STD_STRINGS_IOSTREAM)
39namespace alib {
namespace lang::system {
51void createTempFolderInHomeDir(
const String& folderName,
AString& resultPath,
const NString& reasonMsg );
52void createTempFolderInHomeDir(
const String& folderName,
AString& resultPath,
const NString& reasonMsg )
56 resultPath.Reset( homeTemp.Path );
68 std::ofstream file ( fileName );
72 file <<
"This folder was created by \"" << pi.CmdLine
74 <<
"to be used for temporary files." << std::endl;
75 file.write( reasonMsg.Buffer(), reasonMsg.Length() );
84 resultPath.Reset( homeTemp.Path );
99 #if defined (__unix__)
102 struct passwd* pwd = getpwuid(getuid());
106 #elif defined(__APPLE__)
107 macos::ALIB_APPLE_OC_NSHomeDirectory(
Path );
110 struct passwd* pwd = getpwuid(getuid());
115 #elif defined(_WIN32)
122 #pragma message ("Unknown Platform in file: " __FILE__ )
132 #if defined (__unix__)
134 #elif defined(__APPLE__)
136 #elif defined(_WIN32)
139 #pragma message ("Unknown Platform in file: " __FILE__ )
156 #if defined (__unix__)
157 NString reasonMsg=
"(The default temporary folder \"/tmp\" could not be found.)";
161 #elif defined(__APPLE__)
162 NString reasonMsg=
"(The default temporary folder \"/tmp\" could not be found.)";
171 #elif defined(_WIN32)
172 NString reasonMsg=
"(Environment variables TMP and TEMP either not set or not containing valid paths.)";
180 #pragma message ("Unknown Platform in file: " __FILE__ )
207 #if defined (__unix__)
208 NString reasonMsg=
"(The default folder \"/var/tmp\" could not be found.)";
212 #elif defined(__APPLE__)
213 const NString reasonMsg=
"(The default folder \"/private/var/tmp\" could not be found.)";
218 #elif defined(_WIN32)
219 const NString reasonMsg=
"(Environment variables TMP and TEMP either not set or not containing valid paths.)";
227 #pragma message ("Unknown Platform in file: " __FILE__ )
282 Path.
_<
false>( path ).Terminate();
317 nchar charBuf[FILENAME_MAX];
319 #if defined(__GLIBCXX__) || defined(__APPLE__) || defined(__ANDROID_NDK__)
320 if ( ! getcwd( charBuf,
sizeof(charBuf ) ) )
321 #elif defined ( _WIN32 )
322 if ( !_getcwd( charBuf,
sizeof(charBuf ) ) )
324 #pragma message ("Unknown Platform in file: " __FILE__ )
330 target.
_(
static_cast<const nchar*
>( charBuf ) );
336 #if defined (__GLIBC__) || defined(__APPLE__) || defined(__ANDROID_NDK__)
338 DIR* dir= opendir( nPath );
339 if ( dir !=
nullptr )
346 #elif defined(_WIN32)
348 #if !ALIB_CHARACTERS_WIDE
349 DWORD dwAttrib = GetFileAttributesA( path );
351 DWORD dwAttrib = GetFileAttributesW( path );
353 if( dwAttrib == INVALID_FILE_ATTRIBUTES )
355 if ( dwAttrib & FILE_ATTRIBUTE_DIRECTORY )
360 #pragma message ("Unknown Platform in file: " __FILE__ )
366 #if defined (__GLIBC__) || defined(__APPLE__) || defined(__ANDROID_NDK__)
368 int errCode= mkdir( nPath, S_IRWXU | S_IRGRP | S_IROTH
369 | S_IXGRP | S_IXOTH );
373 #elif defined(_WIN32)
374 #if !ALIB_CHARACTERS_WIDE
375 BOOL result= CreateDirectoryA( path, NULL );
377 BOOL result= CreateDirectoryW( path, NULL );
382 return SystemErrors::OK;
386 #pragma message ("Unknown Platform in file: " __FILE__ )
static ALIB_API SystemErrors Create(const CString &path)
static ALIB_API bool CurrentDirectory(AString &target)
static AString evaluatedVarTempDir
ALIB_API bool Change(const CString &path)
static AString evaluatedTempDir
static ALIB_API bool Exists(const CString &path)
static ALIB_API const ProcessInfo & Current()
TAString & ShortenTo(integer newLength)
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
constexpr bool IsEmpty() const
constexpr integer Length() const
TChar CharAtStart() const
constexpr const TChar * Buffer() const
#define ALIB_WARNINGS_RESTORE
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
platform_specific integer
@ Keep
Chooses not no clear existing data.
lang::system::ProcessInfo ProcessInfo
Type alias in namespace alib.
strings::TAString< nchar > NAString
Type alias in namespace alib.
constexpr nchar DirectorySeparator
lang::system::Directory Directory
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TCString< character > CString
Type alias in namespace alib.
strings::TAString< character > AString
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
LocalString< 16 > String16
Type alias name for TLocalString<character,16> .
static ALIB_API bool Get(const CString &varName, AString &target, lang::CurrentData targetData=lang::CurrentData::Clear)