Pol  Revision:cb584c9
Pol::Module::FileAccess Class Reference

#include <fileaccess.h>

Public Member Functions

 FileAccess (Clib::ConfigElem &elem)
bool AllowsAccessTo (const Plib::Package *pkg, const Plib::Package *filepackage) const
bool AppliesToPackage (const Plib::Package *pkg) const
bool AppliesToPath (const std::string &path, const Plib::Package *filepkg) const
size_t estimateSize () const

Public Attributes

bool AllDirectories
bool AllExtensions
bool AllowAppend
bool AllowRead
bool AllowRemote
bool AllowWrite
bool AllPackages
std::vector< std::pair< const Plib::Package *, std::string > > Directories
std::vector< std::string > Extensions
std::set< const Plib::Package * > Packages

Detailed Description

Definition at line 29 of file fileaccess.h.

Constructor & Destructor Documentation

Pol::Module::FileAccess::FileAccess ( Clib::ConfigElem elem)

I'm thinking that, if anything, I'd want to present a VERY simple, high-level interface.

So no seeking / reading / writing. Something more like this:

  • all filenames are package-relative.
  • Only files in packages can be accessed.
  • ReadFile( filename ); // returns the entire file as an array of lines
  • WriteFile( filename, contents ); // writes a file in its entirely
  • AppendToFile( filename, data );
  • LogToFile( filename, text );

WriteFile and AppendToFile would accept either a string or an array of lines. The string would be written verbatim, while the array of lines would be written with newlines appended.

WriteFile would be atomic for existing files - it would write a new file to a temporary location, then do the rename-rename-delete thing.

LogToFile would take a string as input, and append a newline. It's the equivalent of AppendToFile( filename, array { text } )

Probably a systemwide configuration file would dictate the types of files allowed to be written, and perhaps even name the packages allowed to do so. I could see a use for being able to write .src files, for example. And I'm having thoughts of integrating compile capability directly into pol, and adding something like CompileScript( scriptpath ) to polsys.em


// anyone can append to a log file in their own package
allow append
match *.log
package <all>
// anyone can create .htm files in their own web root
allow write
match www/ *.html
package <all>
// the uploader package is allowed to write .src and .cfg files in any package
allow read
allow write
remote 1
match *.cfg
match *.src
package uploader

Definition at line 112 of file filemod.cpp.

References AllDirectories, AllExtensions, AllPackages, Directories, ERROR_PRINT, Extensions, Pol::Plib::find_package(), Packages, Pol::Plib::pkgdef_split(), and Pol::Clib::ConfigElem::remove_prop().

Referenced by estimateSize().

Member Function Documentation

bool Pol::Module::FileAccess::AllowsAccessTo ( const Plib::Package pkg,
const Plib::Package filepackage 
) const

Definition at line 159 of file filemod.cpp.

References AllowRemote.

bool Pol::Module::FileAccess::AppliesToPackage ( const Plib::Package pkg) const

Definition at line 170 of file filemod.cpp.

References AllPackages, and Packages.

bool Pol::Module::FileAccess::AppliesToPath ( const std::string &  path,
const Plib::Package filepkg 
) const
size_t Pol::Module::FileAccess::estimateSize ( ) const

Definition at line 242 of file filemod.cpp.

References Directories, Extensions, FileAccess(), and Packages.

Member Data Documentation

bool Pol::Module::FileAccess::AllDirectories

Definition at line 45 of file fileaccess.h.

Referenced by AppliesToPath(), and FileAccess().

bool Pol::Module::FileAccess::AllExtensions

Definition at line 46 of file fileaccess.h.

Referenced by AppliesToPath(), and FileAccess().

bool Pol::Module::FileAccess::AllowAppend

Definition at line 39 of file fileaccess.h.

bool Pol::Module::FileAccess::AllowRead

Definition at line 40 of file fileaccess.h.

bool Pol::Module::FileAccess::AllowRemote

Definition at line 42 of file fileaccess.h.

Referenced by AllowsAccessTo().

bool Pol::Module::FileAccess::AllowWrite

Definition at line 38 of file fileaccess.h.

bool Pol::Module::FileAccess::AllPackages

Definition at line 44 of file fileaccess.h.

Referenced by AppliesToPackage(), and FileAccess().

std::vector<std::pair<const Plib::Package*, std::string> > Pol::Module::FileAccess::Directories

Definition at line 49 of file fileaccess.h.

Referenced by AppliesToPath(), estimateSize(), and FileAccess().

std::vector<std::string> Pol::Module::FileAccess::Extensions

Definition at line 50 of file fileaccess.h.

Referenced by AppliesToPath(), estimateSize(), and FileAccess().

std::set<const Plib::Package*> Pol::Module::FileAccess::Packages

Definition at line 48 of file fileaccess.h.

Referenced by AppliesToPackage(), estimateSize(), and FileAccess().

The documentation for this class was generated from the following files: