GDCM 3.0.24
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
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
Class to do system operation.
Definition gdcmSystem.h:27
static bool FileExists(const char *filename)
Check whether the specified file exist on the system.
static const char * GetLocaleCharset()
return locale charmap
static bool FormatDateTime(char date[22], time_t t, long milliseconds=0)
static bool SetPermissions(const char *file, unsigned short mode)
static int StrNCaseCmp(const char *s1, const char *s2, size_t n)
static time_t FileTime(const char *filename)
static const char * GetCurrentResourcesDirectory()
static bool MakeDirectory(const char *path)
Create a directory name path.
static char * StrTokR(char *ptr, const char *sep, char **end)
strtok_r
static bool GetCurrentDateTime(char date[22])
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)
static bool GetHostName(char hostname[255])
static size_t EncodeBytes(char *out, const unsigned char *data, int size)
static bool FileIsSymlink(const char *name)
Check whether name is a symlink.
static char * StrSep(char **stringp, const char *delim)
static const char * GetLastSystemError()
Return the last error.
static std::wstring ConvertToUNC(const char *utf8path)
static const char * GetCWD()
static size_t FileSize(const char *filename)
static int StrCaseCmp(const char *s1, const char *s2)
consistent func for C99 spec of strcasecmp/strncasecmp
static bool FileIsDirectory(const char *name)
Check whether the file specified is a directory:
static const char * GetCurrentModuleFileName()
static bool ParseDateTime(time_t &timep, long &milliseconds, const char date[22])
static bool RemoveFile(const char *source)
remove a file named source
static bool DeleteDirectory(const char *source)
remove a directory named source
static bool GetPermissions(const char *file, unsigned short &mode)
NOT THREAD SAFE.
static const char * GetTimezoneOffsetFromUTC()
static const char * GetCurrentProcessFileName()
#define GDCM_EXPORT
Definition gdcmWin32.h:34
Definition gdcmASN1.h:21