1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
/* -*-c++-*- $Id$ */
/**
* OsgAL - OpenSceneGraph Audio Library
* Copyright (C) 2004 VRlab, Ume University
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#ifndef __OSGAL_FILEPATHCONTAINER_H__
#define __OSGAL_FILEPATHCONTAINER_H__
#ifdef _WIN32
#pragma warning(disable:4786) // Disable warnings about long names
#pragma warning(disable: 4251) // Disable warnings about exporting functions
#endif
#include <string>
#include <list>
#include <fstream>
#include <iostream>
namespace osgAL {
class FilePathContainer
{
#if defined(WIN32) && !defined(__CYGWIN__)
#define FP_PATH_DELIMITER ";"
#else
#define FP_PATH_DELIMITER ":"
#endif
public:
/** Constructor */
FilePathContainer();
/** Constructor - set the file path found in given environment variable */
FilePathContainer(const std::string& env);
/** Destructor */
~FilePathContainer();
/** Set the file path using a single string deliminated with given delimitor */
void setFilePathList(const std::string& paths, const std::string& delimitor = FP_PATH_DELIMITER);
/** Set the file path found in given environment variable - returns true if env var found */
bool setEnvironmentVariable(const std::string& env);
/** Set the file path directly */
void setFilePath(const std::string& path);
/** Adds a list of paths to the previous one */
void FilePathContainer::addFilePath(const std::string& path);
/** Adds a filepath to the end of the list */
void pushbackPath(const std::string& path);
/** Adds a filepath to the beginning of the list */
void pushfrontPath(const std::string& path);
/** Get file path list */
std::list<std::string>& getFilePathList();
/** Get directory from path */
std::string extractDirectory(const std::string& path);
/** Get filename from path */
std::string extractFilename(const std::string& path);
/** Return path to given filename if file exists in any directory */
std::string findFile(const std::string& filename);
private:
/** Path list */
typedef std::list<std::string> PathList;
PathList m_path_list;
/** Convert given string to list with sub strings (seperated by delimitor in string) */
void convertStringToList(const std::string& str, PathList& lst, const std::string& delimitor);
/** Delimitor used when parsing environment varaible */
std::string m_delimiter;
};
} // namespace osgAL
#endif // _FILEPATHCONTAINER_H
/*------------------------------------------
* $Source$
* $Revision$
* $Date$
* $Author$
* $Locker$
* Description:
Copyright (C) Peter Sunna, VRlab, Ume University 2002
Created: 2002-06-26
* $Log$
* Revision 1.1.1.2 2004/12/07 18:15:08 loic
* upstream update osgal-v022-041121.tgz
*
* Revision 1.4 2004/11/19 07:46:09 andersb
* *** empty log message ***
*
* Revision 1.3 2004/04/20 12:26:03 andersb
* Added SoundRoot
*
* Revision 1.2 2004/03/05 09:42:30 andersb
* *** empty log message ***
*
* Revision 1.1 2004/03/03 07:50:49 andersb
* *** empty log message ***
*
*
----------------------------------------------------------------------------*/
|