1 /*---------------------------------------------------------------------------* 2 * PFileSystemImpl.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 __PFILESYSTEMIMPL_H 21 #define __PFILESYSTEMIMPL_H 22 23 24 25 #include "ESR_ReturnCode.h" 26 #include "PortPrefix.h" 27 #include "PFileSystem.h" 28 #include "phashtable.h" 29 30 /** 31 * Portable file-system implementation. 32 */ 33 typedef struct PFileSystemImpl_t 34 { 35 /** 36 * Superinterface. 37 */ 38 PFileSystem super; 39 40 } 41 PFileSystemImpl; 42 43 44 /** 45 * [file path, PFileSystem*] mapping. 46 */ 47 PORTABLE_API PHashTable* PFileSystemPathMap; 48 49 /** 50 * Current working directory. 51 */ 52 PORTABLE_API LCHAR PFileSystemCurrentDirectory[P_PATH_MAX]; 53 54 /** 55 * Default implementation. 56 */ 57 PORTABLE_API ESR_ReturnCode PFileSystemDestroyImpl(PFileSystem* self); 58 59 /** 60 * Initialize PSTDIN, PSTDOUT, PSTDERR. 61 * 62 * @return ESR_OUT_OF_MEMORY if system is out of memory; ESR_INVALID_STATE if mutex could not be created or if this 63 * function is called after the Ptrd module has been shut down. 64 */ 65 PORTABLE_API ESR_ReturnCode PFileSystemInitializeStreamsImpl(void); 66 /** 67 * Shutdown PSTDIN, PSTDOUT, PSTDERR. 68 */ 69 PORTABLE_API ESR_ReturnCode PFileSystemShutdownStreamsImpl(void); 70 71 /** 72 * Associates a base path with the file system. 73 * 74 * For example, if "/dev/cdrom" is specified, then any file under that path 75 * must make use of this file-system. 76 * 77 * @param basePath Base path for files associated with this filesystem 78 * @return ESR_INVALID_ARGUMENT if self or virtualPath or realPath is null or realPath is not a valid path; 79 * ESR_OUT_OF_MEMORY if the system is out of memory; ESR_IDENTIFIER_COLLISION if virtualPath is already mounted. 80 */ 81 PORTABLE_API ESR_ReturnCode PFileSystemAddPathImpl(PFileSystem* self, const LCHAR* basePath); 82 83 /** 84 * Deassociates the file-system from a base path. 85 * 86 * @param self PFileSystem handle 87 * @param basePath Base path for files associated with this filesystem 88 * @return ESR_INVALID_ARGUMENT if self or virtualPath is null or virtualPath is not mounted 89 */ 90 PORTABLE_API ESR_ReturnCode PFileSystemRemovePathImpl(PFileSystem* self, const LCHAR* basePath); 91 92 /** 93 * Given a path, returns the associated file-system and relative path. 94 * 95 * @param path Path to look up 96 * @param fileSystem [out] File-system which matches the path 97 * @param relativePath [out] Relative path associated with match. Set to NULL if this value shouldn't be returned. 98 * Otherwise, the buffer must be of size P_PATH_MAX. 99 * @return ESR_INVALID_ARGUMENT if path, fileSystem or relativePath is null; ESR_INVALID_STATE if no 100 * file-system handles the path 101 */ 102 PORTABLE_API ESR_ReturnCode PFileSystemGetFS(const LCHAR* path, PFileSystem** fileSystem, LCHAR* relativePath); 103 104 /** 105 * Indicates if the specified path refers to a directory. This function does not actually 106 * try resolving the path using a file-system to see if it exists. The result is based purely on the contents 107 * of the string. 108 * 109 * @param path Path to look up 110 * @param isDirectory [out] TRUE if path refers to a directory 111 * @return ESR_INVALID_ARGUMENT if path or isDirectory is null 112 */ 113 PORTABLE_API ESR_ReturnCode PFileSystemIsDirectoryPath(const LCHAR* path, ESR_BOOL* isDirectory); 114 115 #endif /* __PFILESYSTEMIMPL_H */ 116