GDCM: gdcmSystem.h Source File

GDCM 3.2.11

gdcmSystem.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13=========================================================================*/
14#ifndef GDCMSYSTEM_H
15#define GDCMSYSTEM_H
16
17#include "gdcmTypes.h"
18
19namespace gdcm
20{
21
26 class GDCM_EXPORT System
27{
28public:
30 static bool MakeDirectory(const char *path);
32 static bool FileExists(const char* filename);
34 static bool FileIsDirectory(const char* name);
36 static bool FileIsSymlink(const char* name);
38 static bool RemoveFile(const char* source);
40 static bool DeleteDirectory(const char *source);
41
45 static std::wstring ConvertToUNC(const char *utf8path);
46
48 static const char *GetLastSystemError();
49
54 static size_t FileSize(const char* filename);
55
58 static time_t FileTime(const char* filename);
59
62 static const char *GetCurrentProcessFileName();
63
66 static const char *GetCurrentModuleFileName();
67
70 static const char *GetCurrentResourcesDirectory();
71
72 // TODO some system calls
73 // Chdir
74 // copy a file
75
78 static bool GetHostName(char hostname[255]);
79
80 // In the following the size '22' is explicitly listed. You need to pass in
81 // at least 22bytes of array. If the string is an output it will be
82 // automatically padded ( array[21] == 0 ) for you.
83 // Those functions: GetCurrentDateTime / FormatDateTime / ParseDateTime do
84 // not return the &YYZZ part of the DT structure as defined in DICOM PS 3.5 -
85 // 2008 In this case it is simple to split the date[22] into a DA and TM
86 // structure
87
92 static bool GetCurrentDateTime(char date[22]);
93
97 static bool FormatDateTime(char date[22], time_t t, long milliseconds = 0);
98
100 static bool ParseDateTime(time_t &timep, const char date[22]);
101
104 static bool ParseDateTime(time_t &timep, long &milliseconds, const char date[22]);
105
108 static const char *GetTimezoneOffsetFromUTC();
109
112 static size_t EncodeBytes(char *out, const unsigned char *data, int size);
113
115 static int StrCaseCmp(const char *s1, const char *s2);
117 static int StrNCaseCmp(const char *s1, const char *s2, size_t n);
118
123 static const char * GetCWD();
124
126 static char *StrTokR(char *ptr, const char *sep, char **end);
127
131 static char *StrSep(char **stringp, const char *delim);
132
134 static const char *GetLocaleCharset();
135
137/*
138 static void SetArgv0(const char *);
139 static const char* GetArgv0();
140*/
141
142protected:
143 static bool GetPermissions(const char* file, unsigned short& mode);
144 static bool SetPermissions(const char* file, unsigned short mode);
145
146private:
147};
148
149} // end namespace gdcm
150
151#endif //GDCMSYSTEM_H
gdcm::System
Class to do system operation.
Definition gdcmSystem.h:27
gdcm::System::FileExists
static bool FileExists(const char *filename)
Check whether the specified file exist on the system.
gdcm::System::GetLocaleCharset
static const char * GetLocaleCharset()
return locale charmap
gdcm::System::FormatDateTime
static bool FormatDateTime(char date[22], time_t t, long milliseconds=0)
gdcm::System::SetPermissions
static bool SetPermissions(const char *file, unsigned short mode)
gdcm::System::StrNCaseCmp
static int StrNCaseCmp(const char *s1, const char *s2, size_t n)
gdcm::System::FileTime
static time_t FileTime(const char *filename)
gdcm::System::GetCurrentResourcesDirectory
static const char * GetCurrentResourcesDirectory()
gdcm::System::MakeDirectory
static bool MakeDirectory(const char *path)
Create a directory name path.
gdcm::System::StrTokR
static char * StrTokR(char *ptr, const char *sep, char **end)
strtok_r
gdcm::System::GetCurrentDateTime
static bool GetCurrentDateTime(char date[22])
gdcm::System::ParseDateTime
static bool ParseDateTime(time_t &timep, const char date[22])
Parse a date stored as ASCII text into a time_t structured (discard millisecond if any).
gdcm::System::GetHostName
static bool GetHostName(char hostname[255])
gdcm::System::EncodeBytes
static size_t EncodeBytes(char *out, const unsigned char *data, int size)
gdcm::System::FileIsSymlink
static bool FileIsSymlink(const char *name)
Check whether name is a symlink.
gdcm::System::StrSep
static char * StrSep(char **stringp, const char *delim)
gdcm::System::GetLastSystemError
static const char * GetLastSystemError()
Return the last error.
gdcm::System::ConvertToUNC
static std::wstring ConvertToUNC(const char *utf8path)
gdcm::System::GetCWD
static const char * GetCWD()
gdcm::System::FileSize
static size_t FileSize(const char *filename)
gdcm::System::StrCaseCmp
static int StrCaseCmp(const char *s1, const char *s2)
consistent func for C99 spec of strcasecmp/strncasecmp
gdcm::System::FileIsDirectory
static bool FileIsDirectory(const char *name)
Check whether the file specified is a directory:
gdcm::System::GetCurrentModuleFileName
static const char * GetCurrentModuleFileName()
gdcm::System::ParseDateTime
static bool ParseDateTime(time_t &timep, long &milliseconds, const char date[22])
gdcm::System::RemoveFile
static bool RemoveFile(const char *source)
remove a file named source
gdcm::System::DeleteDirectory
static bool DeleteDirectory(const char *source)
remove a directory named source
gdcm::System::GetPermissions
static bool GetPermissions(const char *file, unsigned short &mode)
NOT THREAD SAFE.
gdcm::System::GetTimezoneOffsetFromUTC
static const char * GetTimezoneOffsetFromUTC()
gdcm::System::GetCurrentProcessFileName
static const char * GetCurrentProcessFileName()
gdcmTypes.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21