1/*---------------------------------------------------------------------------*
2 *  PANSIFileSystemImpl.h  *
3 *                                                                           *
4 *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5 *                                                                           *
6 *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7 *  you may not use this file except in compliance with the License.         *
8 *                                                                           *
9 *  You may obtain a copy of the License at                                  *
10 *      http://www.apache.org/licenses/LICENSE-2.0                           *
11 *                                                                           *
12 *  Unless required by applicable law or agreed to in writing, software      *
13 *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15 *  See the License for the specific language governing permissions and      *
16 *  limitations under the License.                                           *
17 *                                                                           *
18 *---------------------------------------------------------------------------*/
19
20#ifndef __PANSIFILESYSTEMIMPL_H
21#define __PANSIFILESYSTEMIMPL_H
22
23
24
25#include "ESR_ReturnCode.h"
26#include "PortPrefix.h"
27#include "PANSIFileSystem.h"
28#include "phashtable.h"
29
30/**
31 * Portable file-system implementation.
32 */
33typedef struct PANSIFileSystemImpl_t
34{
35  /**
36   * Superinterface.
37   */
38  PANSIFileSystem super;
39
40  /**
41   * [virtualPath, realPath] mapping.
42   */
43  PHashTable* directoryMap;
44}
45PANSIFileSystemImpl;
46
47
48/**
49 * ANSI file system, singleton instance.
50 */
51PORTABLE_API PFileSystem* PANSIFileSystemSingleton;
52
53/**
54 * Default implementation.
55 */
56PORTABLE_API ESR_ReturnCode PANSIFileSystemDestroyImpl(PFileSystem* self);
57
58/**
59 * Default implementation.
60 */
61PORTABLE_API ESR_ReturnCode PANSIFileSystemCreatePFileImpl(PFileSystem* self, const LCHAR* path, ESR_BOOL littleEndian, PFile** file);
62
63/**
64 * Default implementation.
65 */
66PORTABLE_API ESR_ReturnCode PANSIFileSystemAddPathImpl(PFileSystem* self, const LCHAR* virtualPath, const LCHAR* realPath);
67
68/**
69 * Default implementation.
70 */
71PORTABLE_API ESR_ReturnCode PANSIFileSystemRemovePathImpl(PFileSystem* self, const LCHAR* virtualPath);
72
73/**
74 * Default implementation.
75 */
76PORTABLE_API ESR_ReturnCode PANSIFileSystemMkdirImpl(PFileSystem* self, const LCHAR* path);
77
78/**
79 * Default implementation.
80 */
81PORTABLE_API ESR_ReturnCode PANSIFileSystemChdirImpl(PFileSystem* self, const LCHAR* path);
82
83/**
84 * Default implementation.
85 */
86PORTABLE_API ESR_ReturnCode PANSIFileSystemGetcwdImpl(PFileSystem* self, LCHAR* cwd, size_t* len);
87
88/**
89 * Given a virtual-path, convert it to a real-path.
90 *
91 * @param self PFileSystem handle
92 * @param path Virtual-path
93 * @param len [out] Size of path argument. If the return code is ESR_BUFFER_OVERFLOW,
94 *            the required length is returned in this variable.
95 */
96PORTABLE_API ESR_ReturnCode PANSIFileSystemGetRealPathImpl(PFileSystem* self, LCHAR* path, size_t* len);
97
98/**
99 * Given a real-path, convert it to a virtual-path.
100 *
101 * @param self PFileSystem handle
102 * @param path Real path
103 * @param len [out] Size of path argument. If the return code is ESR_BUFFER_OVERFLOW,
104 *            the required length is returned in this variable.
105 */
106PORTABLE_API ESR_ReturnCode PANSIFileSystemGetVirtualPathImpl(PFileSystem* self, LCHAR* path, size_t* len);
107
108/**
109 * Default implementation.
110 */
111PORTABLE_API ESR_ReturnCode PFileSystemShutdownStreams(void);
112
113#endif /* __PANSIFILESYSTEMIMPL_H */
114