14a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/*---------------------------------------------------------------------------* 24a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * PANSIFileSystem.h * 34a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * * 44a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Copyright 2007, 2008 Nuance Communciations, Inc. * 54a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * * 64a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the 'License'); * 74a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * you may not use this file except in compliance with the License. * 84a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * * 94a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * You may obtain a copy of the License at * 104a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 * 114a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * * 124a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Unless required by applicable law or agreed to in writing, software * 134a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * distributed under the License is distributed on an 'AS IS' BASIS, * 144a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 154a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * See the License for the specific language governing permissions and * 164a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * limitations under the License. * 174a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * * 184a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project *---------------------------------------------------------------------------*/ 194a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 204a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project#ifndef __PANSIFILESYSTEM_H 214a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project#define __PANSIFILESYSTEM_H 224a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 234a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 244a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 254a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project#include "ESR_ReturnCode.h" 264a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project#include "PortPrefix.h" 274a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project#include "PFileSystem.h" 284a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project#include "ptypes.h" 294a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 304a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 314a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @addtogroup PANSIFileSystemModule PANSIFileSystem API functions 324a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Portable file-system API. 334a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 344a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Must call pmemInit() before using this module. 354a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * If threads are to be used, ptrdInit() must be called before using this module as well. 364a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 374a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * NOTE: It is technically impossible to provide a cross-platform version of scanf() and its 384a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * variants (since vscanf() does not exist). As a result, this module does not provide this 394a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * functionality. End-users are encourages to do their own parsing. 404a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 414a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @{ 424a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 434a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 444a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 454a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Portable ANSI file-system. 464a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 474a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Projecttypedef struct PANSIFileSystem_t 484a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project{ 494a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project /** 504a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Superinterface. 514a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 524a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project PFileSystem super; 534a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 544a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project /** 554a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Mounts an ANSI path. 564a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 574a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * For example, if "c:/" is mounted as "/dev/c", then any file referenced under "/dev/c" will access 584a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * "c:/" under the hood. 594a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 604a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param self PFileSystem handle 614a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param virtualPath PFileSystem path 624a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param realPath ANSI path 634a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_INVALID_ARGUMENT if self or virtualPath or realPath is null or realPath is not a valid path; 644a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * ESR_OUT_OF_MEMORY if the system is out of memory; ESR_IDENTIFIER_COLLISION if virtualPath is already mounted. 654a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 664a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project ESR_ReturnCode(*addPath)(PFileSystem* self, const LCHAR* virtualPath, const LCHAR* realPath); 674a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 684a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project /** 694a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Deassociates the file-system from a base path. 704a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 714a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param self PFileSystem handle 724a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param virtualPath PFileSystem path 734a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_INVALID_ARGUMENT if self or virtualPath is null or virtualPath is not mounted 744a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 754a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project ESR_ReturnCode(*removePath)(PFileSystem* self, const LCHAR* virtualPath); 764a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project /** 774a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Returns the current working directory from the operating-system's point of view. 784a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * This differs from PFileSystemGetcwd() in that the latter returns the current working 794a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * directory on the virtual file-system while this function returns the native working directory. 804a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 814a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param self PFileSystem handle 824a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param cwd [out] Current working directory 834a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param len [in/out] Length of path argument. If the return code is ESR_BUFFER_OVERFLOW, 844a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * the required length is returned in this variable. 854a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_INVALID_ARGUMENT if self or cwd is null; ESR_BUFFER_OVERFLOW if cwd is not large enough to contain result; 864a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * ESR_INVALID_STATE if operating-system returns unexpected value. 874a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 884a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project ESR_ReturnCode(*getcwd)(PFileSystem* self, LCHAR* cwd, size_t* len); 894a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project} 904a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source ProjectPANSIFileSystem; 914a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 924a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 934a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Initializes the ANSI file-system module. 944a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 954a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_OUT_OF_MEMORY if system is out of memory; ESR_INVALID_STATE if mutex could not be created or if this 964a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * function is called after the Ptrd module has been shut down. 974a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 984a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source ProjectPORTABLE_API ESR_ReturnCode PANSIFileSystemCreate(void); 994a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 1004a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 1014a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Shuts down the ANSI file-system module. 1024a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1034a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_SUCCESS 1044a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 1054a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source ProjectPORTABLE_API ESR_ReturnCode PANSIFileSystemDestroy(void); 1064a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 1074a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 1084a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Mounts an ANSI path. 1094a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1104a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * For example, if "c:/" is mounted as "/dev/c", then any file referenced under "/dev/c" will access 1114a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * "c:/" under the hood. 1124a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1134a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param virtualPath PFileSystem path 1144a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param realPath ANSI path 1154a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_INVALID_ARGUMENT if self or virtualPath or realPath is null or realPath is not a valid path; 1164a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * ESR_OUT_OF_MEMORY if the system is out of memory; ESR_IDENTIFIER_COLLISION if virtualPath is already mounted. 1174a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 1184a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source ProjectPORTABLE_API ESR_ReturnCode PANSIFileSystemAddPath(const LCHAR* virtualPath, const LCHAR* realPath); 1194a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 1204a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 1214a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Deassociates the file-system from a base path. 1224a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1234a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param virtualPath PFileSystem path 1244a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_INVALID_ARGUMENT if self or virtualPath is null or virtualPath is not mounted 1254a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 1264a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source ProjectPORTABLE_API ESR_ReturnCode PANSIFileSystemRemovePath(const LCHAR* virtualPath); 1274a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 1284a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 1294a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Returns a virtual path associated with the current ANSI directory. 1304a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1314a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * For example, if "/dev/ansi" is mapped to "/" and the current ANSI directory is "/usr/bin" then 1324a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * this function will return "/dev/ansi/usr/bin". 1334a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1344a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * If multiple virtual paths correspond to the current ANSI directory, the first one will be returned. 1354a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1364a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param cwd [out] Current working directory 1374a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param len [in/out] Length of path argument. If the return code is ESR_BUFFER_OVERFLOW, 1384a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * the required length is returned in this variable. 1394a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_INVALID_ARGUMENT if self or cwd is null; ESR_BUFFER_OVERFLOW if cwd is not large enough to contain result; 1404a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * ESR_INVALID_STATE if operating-system returns unexpected value. 1414a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 1424a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source ProjectPORTABLE_API ESR_ReturnCode PANSIFileSystemGetcwd(LCHAR* cwd, size_t* len); 1434a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 1444a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 1454a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * Indicates if this file-system should act as the default file-system. 1464a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * If a path is specified which does not match any other file-system, it is resolved using this one. 1474a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * 1484a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @param isDefault True if the file-system should be the default file-system 1494a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @return ESR_OUT_OF_MEMORY if system is out of memory 1504a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 1514a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source ProjectPORTABLE_API ESR_ReturnCode PANSIFileSystemSetDefault(ESR_BOOL isDefault); 1524a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project 1534a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project/** 1544a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project * @} 1554a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project */ 1564a68b3365c8c50aa93505e99ead2565ab73dcdb0The Android Open Source Project#endif /* __PANSIFILESYSTEM_H */ 157