gdcmSystem.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program: GDCM (Grassroots DICOM). A DICOM library
00004   Module:  $URL$
00005 
00006   Copyright (c) 2006-2010 Mathieu Malaterre
00007   All rights reserved.
00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 #ifndef GDCMSYSTEM_H
00016 #define GDCMSYSTEM_H
00017 
00018 #include "gdcmTypes.h"
00019 
00020 namespace gdcm
00021 {
00022 
00027 class GDCM_EXPORT System
00028 {
00029 public:
00031   static bool MakeDirectory(const char *path);
00033   static bool FileExists(const char* filename);
00035   static bool FileIsDirectory(const char* name);
00037   static bool RemoveFile(const char* source);
00038   //static bool DeleteDirectory(FilenameType const &name) { (void)name; return false; }; // TODO
00039 
00041   static const char *GetLastSystemError();
00042 
00047   static size_t FileSize(const char* filename);
00048 
00051   static time_t FileTime(const char* filename);
00052 
00055   static const char *GetCurrentProcessFileName();
00056 
00059   static const char *GetCurrentModuleFileName();
00060 
00063   static const char *GetCurrentResourcesDirectory();
00064 
00065   // TODO some system calls
00066   // Chdir
00067   // copy a file
00068 
00070   static bool GetHardwareAddress(unsigned char addr[6]);
00071 
00074   static bool GetHostName(char hostname[255]);
00075 
00076   // somewhat UID specific:
00077   // In the following the size '22' is explicitely listed. You need to pass in at least 22bytes of
00078   // array. If the string is an output it will be automatically padded ( array[21] == 0 ) for you.
00079   // Those functions: GetCurrentDateTime / FormatDateTime / ParseDateTime do not return the 
00080   // &YYZZ part of the DT structure as defined in DICOM PS 3.5 - 2008
00081   // In this case it is simple to split the date[22] into a DA and TM structure !
00082 
00084   // That's simply a call to gettimeofday + FormatDateTime, but since WIN32 do not have an 
00085   // implementation for gettimeofday this is more portable. (and time(0) is not precise)
00086   static bool GetCurrentDateTime(char date[22]);
00087 
00091   static bool FormatDateTime(char date[22], time_t t, long milliseconds = 0);
00092 
00094   static bool ParseDateTime(time_t &timep, const char date[22]);
00095 
00098   static bool ParseDateTime(time_t &timep, long &milliseconds, const char date[22]);
00099 
00101   static size_t EncodeBytes(char *out, const unsigned char *data, int size);
00102 
00104   static int StrCaseCmp(const char *s1, const char *s2);
00106   static int StrNCaseCmp(const char *s1, const char *s2, size_t n);
00107 
00112   static const char * GetCWD();
00113 
00115 /*
00116   static void SetArgv0(const char *);
00117   static const char* GetArgv0();
00118 */
00119 
00120 protected:
00121   static bool GetPermissions(const char* file, unsigned short& mode);
00122   static bool SetPermissions(const char* file, unsigned short mode);
00123 
00124 private:
00125 };
00126 
00127 } // end namespace gdcm
00128 
00129 #endif //GDCMSYSTEM_H

Generated on Sat Dec 4 2010 08:58:47 for GDCM by doxygen 1.7.2
SourceForge.net Logo