|
File
Version:revision 6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
-
-
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
|
!
|
#pragma once
#include <apcl/file/FileType.hpp>
#include <apcl/file/FilePath.hpp>
#include <apcl/util/Data.hpp>
namespace apcl { namespace file
{
using ::apcl::util::Data;
class File
{
public:
File();
virtual ~File();
const FilePath& path()const;
void setPath( const FilePath& );
const Data& data()const;
void setData( const Data& );
FileType type()const;
void setType( FileType );
private:
FilePath path_;
Data data_;
FileType type_;
};
}}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-
!
-
!
-
|
!
-
|
!
-
|
!
-
|
!
-
|
!
-
|
!
|
#include <apcl/file/File.hpp>
using namespace ::apcl::file;
File::File():
type_( FileType_Binary )
{
}
File::~File()
{
}
const FilePath& File::path()const
{
return path_;
}
void File::setPath( const FilePath& aPath )
{
path_ = aPath;
}
const Data& File::data()const
{
return data_;
}
void File::setData( const Data& aData )
{
data_ = aData;
}
FileType File::type()const
{
return type_;
}
void File::setType( const FileType aType )
{
type_ = aType;
}
|
FilePath
Version:revision 6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
-
-
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
!
|
!
!
|
#pragma once
#include <string>
namespace apcl { namespace file
{
using ::std::string;
class FilePath
{
public:
FilePath();
virtual ~FilePath();
void setPath( const string& aFilePath );
const string& path()const;
private:
string path_;
};
} }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-
!
-
!
-
|
!
-
|
!
|
#include <apcl/file/FilePath.hpp>
using namespace ::apcl::file;
FilePath::FilePath()
{
}
FilePath::~FilePath()
{
}
void FilePath::setPath( const string& aPath )
{
path_ = aPath;
}
const string& FilePath::path()const
{
return path_;
}
|
FileSaver
Version:revision 6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
-
-
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
!
|
!
!
|
#pragma once
#include <apcl/file/File.hpp>
namespace apcl { namespace file
{
class FileSaver
{
public:
FileSaver( const File& ); virtual ~FileSaver();
const File& file()const;
bool save()const;
private:
const File file_;
};
} }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
!
-
!
-
|
!
-
|
|
|
|
|
|
|
|
-
|
!
|
|
|
|
|
|
|
|
!
|
#include <apcl/file/FileSaver.hpp>
#include <apcl/file/File.hpp>
#include <apcl/file/FilePath.hpp>
#include <apcl/util/Data.hpp>
#include <fstream>
using namespace ::apcl::file;
using namespace ::apcl::util;
FileSaver::FileSaver( const File& aFile ):
file_( aFile )
{
}
FileSaver::~FileSaver()
{
}
const File& FileSaver::file()const
{
return file_;
}
bool FileSaver::save()const
{
std::ios_base::open_mode mode = std::ios_base::out;
if ( file_.type() == FileType_Binary )
mode |= std::ios::binary;
std::ofstream out( file_.path().path().c_str() , mode );
if ( !out.is_open() )
{ return false;
}
out.write( reinterpret_cast<const char*>( file_.data().bytes() ) , file_.data().length() );
out.close();
return true;
}
|
FileType
Version:revision 6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
-
-
|
|
-
|
|
|
|
|
!
|
!
!
|
#pragma once
namespace apcl { namespace file
{
enum FileType
{
FileType_Binary = 0 , FileType_Ascii , FileType_Terminate,
FileType_Begin = 0 ,
FileType_End = FileType_Terminate
};
} }
|
1
2
|
|
#include <apcl/file/FileType.hpp>
|
|