Zorba
The XQuery Processor
Documentation
Live Demo
Modules
Download
Tools
Blog
Code
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
include
zorba
util
util/file.h
Go to the documentation of this file.
1
/*
2
* Copyright 2006-2008 The FLWOR Foundation.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef ZORBA_FILE_H
18
#define ZORBA_FILE_H
19
20
#ifndef WIN32
21
#include <stdint.h>
22
#endif
23
24
#include <cstdio>
25
#include <string>
26
#include <
time.h
>
27
#include <vector>
28
29
#include <zorba/config.h>
30
#include <
zorba/file.h
>
31
#include <
zorba/util/path.h
>
32
33
namespace
zorba {
34
35
class
ZORBA_DLL_PUBLIC
file
:
public
filesystem_path
36
{
37
public
:
38
39
enum
filetype
{
40
type_invalid
,
41
type_non_existent
,
42
type_directory
,
43
type_link
,
44
type_file
,
45
type_volume
,
46
type_other
47
};
48
49
typedef
zorba::File::FileSize_t
file_size_t
;
50
51
protected
:
52
filetype
type
;
53
54
// file attributes
55
file_size_t
size
;
// size in bytes
56
57
void
do_stat();
58
59
public
:
60
file
(
const
filesystem_path
&path,
int
flags = 0);
61
62
public
:
// common methods
63
void
set_path
(std::string
const
& _path ) { *((
filesystem_path
*)
this
) = _path; }
64
void
set_filetype
(
enum
filetype
_type ) {
type
= _type ; }
65
enum
filetype get_filetype();
66
67
bool
is_directory
()
const
{
return
(
type
==type_directory); }
68
bool
is_file
()
const
{
return
(
type
==type_file); }
69
bool
is_link
()
const
{
return
(
type
==type_link); }
70
bool
is_volume
()
const
{
return
(
type
==type_volume); }
71
72
bool
is_invalid
()
const
{
return
(
type
==type_invalid); }
73
bool
exists
()
const
{
return
(
type
!=type_non_existent &&
type
!=type_invalid); }
74
75
time_t lastModified();
76
77
public
:
// file methods
78
void
create();
79
void
remove
(
bool
ignore =
true
);
80
void
rename(std::string
const
& newpath);
81
82
file_size_t
get_size
()
const
{
return
size; }
83
84
public
:
// directory methods
85
void
mkdir();
86
void
deep_mkdir();
87
void
rmdir(
bool
ignore =
true
);
88
void
lsdir(std::vector<std::string> &list);
89
#ifndef _WIN32_WCE
90
void
chdir();
91
#endif
92
93
bool
is_empty
()
const
{
return
(size == (
file_size_t
)0); }
94
};
95
96
97
}
// namespace zorba
98
#endif
/* ZORBA_FILE_H */
99
/*
100
* Local variables:
101
* mode: c++
102
* End:
103
*/
104
/* vim:set et sw=2 ts=2: */
Please enable JavaScript to view the
comments powered by Disqus.
blog comments powered by
Disqus