
#ifndef __WFX_IO_FILE_H__
#define __WFX_IO_FILE_H__

#include <WFX/WFXIncludes.h>

namespace WFX {

    namespace io {

        /**
         * An abstract representation of file and directory pathnames.
         * Paths should be given in a unix-like notation, 
         * e.g. /home/foo/file or ./data/file
         * this currently only works with linux, TODO: make this system
         * independant
         */
        class File {
            public:
                /** 
                 * Ctor
                 */
                File(std::string path);

                /**
                 * returns a string representing
                 * this file
                 */
                std::string toString() const {
                    return Path;
                }

                /**
                 * returns the file extension
                 * returns an empty string if no extension
                 * is found, also throws an exception
                 *
                 * @throws: WFXException if no extension was found
                 *
                 */
                std::string getExt() const;

                /** returns a string representing the directory name */
                std::string getDir() const;

                /**
                 * returns true if this File is a directory
                 */
                bool isDirectory() const;

                /**
                 * returns true if this File is a normal file
                 */
                bool isFile() const;

                /** convenience operators */
                inline File operator =(const File& f) {
                    Path = f.Path;
                    return *this;
                }
                inline bool operator ==(const File& f) const {
                    return (Path==f.Path);
                }
                inline bool operator !=(const File& f) const {
                    return (Path!=f.Path);
                }
                inline bool operator >(const File& f) const {
                    return (Path > f.Path);
                }
                inline bool operator <(const File& f) const {
                    return (Path < f.Path);
                }

                /**
                 * strips the given String from the absolute Path
                 * and returns the result
                 */
                std::string getPathPart(const std::string& pre);


            protected:
            private:
                /**
                 * the absolute pathname
                 */
                std::string Path;

                /**
                 * converts the given path to an abslute path
                 */
                std::string toAbsolutePath(std::string p);

        };

    }

}

#endif //include guard


