TrinityCore
Loading...
Searching...
No Matches
DB2FileSystemSource.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#include "
DB2FileSystemSource.h
"
19
#include <boost/filesystem/operations.hpp>
20
21
DB2FileSystemSource::DB2FileSystemSource
(std::string
const
& fileName)
22
{
23
_fileName
= fileName;
24
_file
= fopen(
_fileName
.c_str(),
"rb"
);
25
}
26
27
DB2FileSystemSource::~DB2FileSystemSource
()
28
{
29
if
(
_file
)
30
fclose(
_file
);
31
}
32
33
bool
DB2FileSystemSource::IsOpen
()
const
34
{
35
return
_file
!=
nullptr
;
36
}
37
38
bool
DB2FileSystemSource::Read
(
void
* buffer, std::size_t numBytes)
39
{
40
return
fread(buffer, numBytes, 1,
_file
) == 1;
41
}
42
43
int64
DB2FileSystemSource::GetPosition
()
const
44
{
45
return
ftell(
_file
);
46
}
47
48
bool
DB2FileSystemSource::SetPosition
(
int64
position)
49
{
50
return
fseek(
_file
, position, SEEK_SET) == 0;
51
}
52
53
int64
DB2FileSystemSource::GetFileSize
()
const
54
{
55
boost::system::error_code error;
56
int64
size = boost::filesystem::file_size(
_fileName
, error);
57
return
!error ? size : 0;
58
}
59
60
char
const
*
DB2FileSystemSource::GetFileName
()
const
61
{
62
return
_fileName
.c_str();
63
}
64
65
DB2EncryptedSectionHandling
DB2FileSystemSource::HandleEncryptedSection
(
DB2SectionHeader
const
&
/*sectionHeader*/
)
const
66
{
67
return
DB2EncryptedSectionHandling::Skip
;
68
}
DB2EncryptedSectionHandling
DB2EncryptedSectionHandling
Definition
DB2FileLoader.h:95
DB2EncryptedSectionHandling::Skip
@ Skip
DB2FileSystemSource.h
int64
int64_t int64
Definition
Define.h:149
DB2FileSystemSource::~DB2FileSystemSource
~DB2FileSystemSource()
Definition
DB2FileSystemSource.cpp:27
DB2FileSystemSource::GetFileName
char const * GetFileName() const override
Definition
DB2FileSystemSource.cpp:60
DB2FileSystemSource::IsOpen
bool IsOpen() const override
Definition
DB2FileSystemSource.cpp:33
DB2FileSystemSource::_fileName
std::string _fileName
Definition
DB2FileSystemSource.h:41
DB2FileSystemSource::GetPosition
int64 GetPosition() const override
Definition
DB2FileSystemSource.cpp:43
DB2FileSystemSource::_file
FILE * _file
Definition
DB2FileSystemSource.h:42
DB2FileSystemSource::DB2FileSystemSource
DB2FileSystemSource(std::string const &fileName)
Definition
DB2FileSystemSource.cpp:21
DB2FileSystemSource::GetFileSize
int64 GetFileSize() const override
Definition
DB2FileSystemSource.cpp:53
DB2FileSystemSource::Read
bool Read(void *buffer, std::size_t numBytes) override
Definition
DB2FileSystemSource.cpp:38
DB2FileSystemSource::HandleEncryptedSection
DB2EncryptedSectionHandling HandleEncryptedSection(DB2SectionHeader const §ionHeader) const override
Definition
DB2FileSystemSource.cpp:65
DB2FileSystemSource::SetPosition
bool SetPosition(int64 position) override
Definition
DB2FileSystemSource.cpp:48
DB2SectionHeader
Definition
DB2FileLoader.h:57
common
DataStores
DB2FileSystemSource.cpp
Generated on Sun May 10 2026 02:08:51 for TrinityCore by
1.9.8