2005-02-06 21:30:09 +00:00
|
|
|
//This file is part of Photon (http://photon.sourceforge.net)
|
|
|
|
//Copyright (C) 2004-2005 James Turk
|
|
|
|
//
|
|
|
|
// Author:
|
|
|
|
// James Turk (jpt2433@rit.edu)
|
|
|
|
//
|
|
|
|
// Version:
|
2005-03-02 08:39:03 +00:00
|
|
|
// $Id: filesys.hpp,v 1.3 2005/03/02 08:39:03 cozman Exp $
|
2005-02-06 21:30:09 +00:00
|
|
|
|
2005-02-13 22:12:02 +00:00
|
|
|
#ifndef PHOTON_UTIL_FILESYS_FILESYS_HPP
|
|
|
|
#define PHOTON_UTIL_FILESYS_FILESYS_HPP
|
2005-02-06 21:30:09 +00:00
|
|
|
|
2005-02-13 22:12:02 +00:00
|
|
|
#include "exceptions.hpp"
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
#include "physfs.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2005-03-02 08:39:03 +00:00
|
|
|
// Title: filesys::
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
namespace photon
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
namespace filesys
|
|
|
|
{
|
|
|
|
|
|
|
|
// Group: System Directories ///////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Function: getCDDirs
|
|
|
|
// Gets a listing of the CD directories on a system (not supported on all
|
|
|
|
// systems)
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// A vector of strings containing the path to the CD directories.
|
|
|
|
std::vector<std::string> getCDDirs();
|
|
|
|
|
|
|
|
// Function: getBaseDir
|
|
|
|
// Get the path to the directory that the application is running in.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// Path to directory that application is running from.
|
|
|
|
std::string getBaseDir();
|
|
|
|
|
|
|
|
// Function: getUserDir
|
|
|
|
// Get the path to the directory that the OS specifies for the user's home.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// Path to user's home directory.
|
|
|
|
std::string getUserDir();
|
|
|
|
|
|
|
|
// Group: Search Path //////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Function: addToSearchPath
|
|
|
|
// Attempts to add a directory to the search path.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// dir - Directory to add to the search path
|
|
|
|
// append - if true, directory will be added to end of path
|
|
|
|
// if false, directory will be added to front of path
|
|
|
|
//
|
|
|
|
// See Also:
|
|
|
|
// <removeFromSearchPath>
|
|
|
|
// <getSearchPath>
|
2005-02-07 01:48:50 +00:00
|
|
|
void addToSearchPath(const std::string& dir, bool append);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
// Function: removeFromSearchPath
|
|
|
|
// Removes a directory from the search path, if it exists on the path.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// dir - Directory to remove from the search path, if it doesn't exist
|
|
|
|
// nothing happens.
|
|
|
|
//
|
|
|
|
// See Also:
|
|
|
|
// <addToSearchPath>
|
|
|
|
// <getSearchPath>
|
2005-02-07 01:48:50 +00:00
|
|
|
void removeFromSearchPath(const std::string& dir);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
// Function: getSearchPath
|
|
|
|
// Obtain the currently configured search path.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// List of strings in search path.
|
|
|
|
//
|
|
|
|
// See Also:
|
|
|
|
// <addToSearchPath>
|
|
|
|
// <removeFromSearchPath>
|
|
|
|
std::vector<std::string> getSearchPath();
|
|
|
|
|
|
|
|
// Group: Manipulation /////////////////////////////////////////////////////////
|
|
|
|
|
2005-02-07 01:48:50 +00:00
|
|
|
// Function: setWriteDir
|
|
|
|
// Sets the writing directory, used by <mkdir> and <remove>.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// dir - Directory to make writeable
|
|
|
|
//
|
|
|
|
// See Also:
|
|
|
|
// <getWriteDir>
|
|
|
|
void setWriteDir(const std::string& dir);
|
|
|
|
|
|
|
|
// Function: getWriteDir
|
|
|
|
// Gets the writing directory.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// Writable directory, if set.
|
|
|
|
//
|
|
|
|
// See Also:
|
|
|
|
// <setWriteDir>
|
|
|
|
std::string getWriteDir();
|
|
|
|
|
2005-02-06 21:30:09 +00:00
|
|
|
// Function: mkdir
|
|
|
|
// Attempts to create a directory.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// dir - name of directory to create
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// true iff directory was created, false if not
|
2005-02-07 01:48:50 +00:00
|
|
|
bool mkdir(const std::string& dir);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
// Function: remove
|
|
|
|
// Attempts to remove a file or directory.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// remove - name of file or directory to remove
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// true iff file/directory was removed, false if not
|
2005-02-07 01:48:50 +00:00
|
|
|
bool remove(const std::string& item);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
// Group: Searching ////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Function: listDir
|
|
|
|
// Lists the contents of a directory.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// dir - name of directory to get contents of
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// list of strings representing items found in 'dir'
|
2005-02-07 01:48:50 +00:00
|
|
|
std::vector<std::string> listDir(const std::string& dir);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
// Function: exists
|
|
|
|
// Checks if a file/directory exists.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// item - file/directory to check existance of
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// true iff file/directory exists, false if not
|
2005-02-07 01:48:50 +00:00
|
|
|
bool exists(const std::string& item);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
2005-02-07 01:48:50 +00:00
|
|
|
// Function: isDir
|
2005-02-06 21:30:09 +00:00
|
|
|
// Checks if a name refers to a directory.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// item - name to check
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// true iff item is a directory, false if not
|
2005-02-07 01:48:50 +00:00
|
|
|
bool isDir(const std::string& item);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
// Function: isSymbolicLink
|
|
|
|
// Checks if a name refers to a symbolic link.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// item - name to check
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// true iff item is a symbolic link, false if not
|
2005-02-07 01:48:50 +00:00
|
|
|
bool isSymbolicLink(const std::string& item);
|
|
|
|
|
|
|
|
// Group: Other ////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Function: getDirSeparator
|
|
|
|
// Gets the system standard directory separator.
|
|
|
|
// (/ on unix, \\ on windows, : on MacOS)
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// System directory separator.
|
|
|
|
std::string getDirSeparator();
|
|
|
|
|
|
|
|
// Function: permitSymbolicLinks
|
|
|
|
// Enables or disables symbolic linking. (which is off by default)
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// allow - true if you wish to enable linking, false if you wish to disable it
|
|
|
|
void permitSymbolicLinks(bool allow);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
// Function: getModTime
|
|
|
|
// Gets last modification time for a file.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// item - name of item to get last modification time of
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// Last modification time of a file in seconds since the epoch.
|
2005-02-07 01:48:50 +00:00
|
|
|
PHYSFS_sint64 getModTime(const std::string& item);
|
2005-02-06 21:30:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-13 22:12:02 +00:00
|
|
|
#endif //PHOTON_UTIL_FILESYS_FILESYS_HPP
|