DCL 3.7.4
Loading...
Searching...
No Matches
Files.h
Go to the documentation of this file.
1#ifndef __DCL_FILES_H__
2#define __DCL_FILES_H__ 20241218
3
4#ifndef __DCL_CONFIG_H__
5#include <dcl/Config.h>
6#endif
7#ifndef __DCL_STRING_H__
8#include <dcl/String.h>
9#endif
10#ifndef __DCL_CHARSET_H__
11#include <dcl/Charset.h>
12#endif
13#ifndef __DCL_DATE_TIME_H__
14#include <dcl/DateTime.h>
15#endif
16#ifndef __DCL_EXCEPTION_H__
17#include <dcl/Exception.h>
18#endif
19
20__DCL_BEGIN_NAMESPACE
21
22class InputStream;
23class OutputStream;
24
25class DCLCAPI Files
26{
27private:
28 Files() {}
29
30public:
31 // static members
32 // File2.cpp
33
35 {
38 EXECUTE_OK = 1, // windows 무시
39 EXISTS = 0,
40 };
41
47 static bool access(const String& _path, int _mode);
48
49 static void rename(const String& _oldpath, const String& _newpath)
51
52 // unlink and rmdir
53 static void remove(const String& _path)
55
56 // path를 삭제
57 static void unlink(const String& _path)
59
60 // path 의 존재 유무 체크access(path, F_OK), 있으면 true
61 // path가 심볼릭 링크이면 원본 체크
62 static bool exists(const String& _path);
63
64 // 파일의 디렉토리 여부를 판별한다.
65 static bool isDirectory(const String& _path);
66
70 static DateTime mtime(const String& _path)
72
73 /*
74 * 파일의 최종 접근, 수정, 생성 시간을 얻는다.
75 */
76 static bool time(
77 const String& _path,
78 time_t* _atime, time_t* _mtime, time_t* _ctime
79 );
80
81 // 파일이 없거나 접근 불능등의 에러이면 예외
82 static uint64_t size(const String& _path)
84
85 // 프로세스의 작업 디렉토리 변경
86 static void chdir(const String& _path)
88
89 // 프로세스의 현재 디렉토리(current working directory)
90 static String getcwd() __DCL_THROWS1(IOException*);
91
92 // 디렉토리 생성, windows에서 nMode 무시
93 static void mkdir(const String& _path, int _mode = 0755)
95
96 // 디렉토리 삭제
97 static void rmdir(const String& _path)
99
100 // path에서 파일명을 리턴, "dir/a" ==> "a"
101 static String basename(const String& _path);
102
103 // path에서 디렉토리명을 리턴, "dir/abc" ==> "dir/"
104 // 리턴값문자열의 끝은 디렉토리 구분자('/', '\', ':')를 포함
105 static String dirname(const String& _path);
106
107 // path에서 디렉토리 구분자(default '/')를 리턴
108 static wchar_t delimiter(const String& _path);
109
110 // pszDirName에서 디렉토리 구분자를 찾아서
111 // pszDirName + 'delimiter char + pszBaseName 리턴
112 static String filename(
113 const String& _dirname,
114 const String& _basename
115 );
116
117 // $TMP, $TEMP, /tmp 중 리턴, 셋 모두 실패하면 빈 String
118 // 리턴값문자열의 끝은 디렉토리 구분자('/', '\')를 포함
119 static String temppath();
120
121 // 상대경로명을 절대경로명으로 리턴
122 static String realpath(const String& _path)
124
125 // "dir\dir\name" return "dir/dir/name"
126 static String unixpath(const String& _path);
127
128 // \, /, "C:, D:, ... return true
129 static bool isAbsPath(const String& _path);
130
131 static ByteString readBytes(InputStream& _input, size_t _n = (size_t)-1)
133
134 static ByteString readBytes(const String& _filename, size_t _n = (size_t)-1)
136
137 // UTF8, UTF16, UTF32, LC_CTYPE
138 static String readText(const String& _filename)
140
141 static String readText(const String& _filename, CharsetDecoder& _decoder)
143
144 static size_t copy(InputStream& _input, OutputStream& _output)
146};
147
148__DCL_END_NAMESPACE
149
150#endif // __DCL_FILES_H__
#define DCLCAPI
Definition Config.h:95
#define __DCL_THROWS1(e)
Definition Config.h:152
AccessType
Definition Files.h:35
@ EXISTS
Definition Files.h:39
@ READ_OK
Definition Files.h:36
@ WRITE_OK
Definition Files.h:37
@ EXECUTE_OK
Definition Files.h:38