TrinityCore
CascHandles.h
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#ifndef CascHandles_h__
19#define CascHandles_h__
20
21#include "Define.h"
22#include <CascPort.h>
23
24namespace boost
25{
26 namespace filesystem
27 {
28 class path;
29 }
30}
31
32namespace CASC
33{
34 char const* HumanReadableCASCError(uint32 error);
35
36 class File;
37
38 class Storage
39 {
40 public:
41 ~Storage();
42
43 static Storage* Open(boost::filesystem::path const& path, uint32 localeMask, char const* product);
44 static Storage* OpenRemote(boost::filesystem::path const& path, uint32 localeMask, char const* product, char const* region);
45
46 uint32 GetBuildNumber() const;
48 bool HasTactKey(uint64 keyLookup) const;
49
50 File* OpenFile(char const* fileName, uint32 localeMask, bool printErrors = false, bool zerofillEncryptedParts = false) const;
51 File* OpenFile(uint32 fileDataId, uint32 localeMask, bool printErrors = false, bool zerofillEncryptedParts = false) const;
52
53 private:
54 Storage(HANDLE handle);
55
56 bool LoadOnlineTactKeys();
57
58 HANDLE _handle;
59 };
60
61 class File
62 {
63 friend File* Storage::OpenFile(char const* fileName, uint32 localeMask, bool printErrors, bool zerofillEncryptedParts) const;
64 friend File* Storage::OpenFile(uint32 fileDataId, uint32 localeMask, bool printErrors, bool zerofillEncryptedParts) const;
65
66 public:
67 ~File();
68
69 uint32 GetId() const;
70 int64 GetSize() const;
71 int64 GetPointer() const;
72 bool SetPointer(int64 position);
73 bool ReadFile(void* buffer, uint32 bytes, uint32* bytesRead);
74
75 private:
76 File(HANDLE handle);
77
78 HANDLE _handle;
79 };
80}
81
82#endif // CascHandles_h__
int64_t int64
Definition: Define.h:137
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
uint32 GetId() const
int64 GetSize() const
bool SetPointer(int64 position)
int64 GetPointer() const
HANDLE _handle
Definition: CascHandles.h:78
bool ReadFile(void *buffer, uint32 bytes, uint32 *bytesRead)
File(HANDLE handle)
bool HasTactKey(uint64 keyLookup) const
uint32 GetBuildNumber() const
static Storage * OpenRemote(boost::filesystem::path const &path, uint32 localeMask, char const *product, char const *region)
static Storage * Open(boost::filesystem::path const &path, uint32 localeMask, char const *product)
Storage(HANDLE handle)
uint32 GetInstalledLocalesMask() const
File * OpenFile(char const *fileName, uint32 localeMask, bool printErrors=false, bool zerofillEncryptedParts=false) const
bool LoadOnlineTactKeys()
HANDLE _handle
Definition: CascHandles.h:58
char const * HumanReadableCASCError(uint32 error)
Definition: CascHandles.cpp:30