/*=============================================================================
Copyright (C) 2001 Silicon Tao Technology Systems
E-mail: Support
Web: www.silicontao.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
=============================================================================*/
/*=============================================================================
File Name: STDriveOps.h
Object Name: STDriveOps
Programmer Name: Roy Souther
By Command of: Silicon Tao Technology Systems
License: GNU general public license. See GNU.
Day Zero: 02152000, Feburary 15, 2000
Target Platform: Linux
Registors Used:
Compiler Used: GNU g++
Compiled Settings:
Resources Used:
Libraries Used: alloc.h, stdio.h, string.h
Ports Used: None
Title of program: Object library
=============================================================================*/
#ifndef STDriveOps_included
#define STDriveOps_included
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#define ENOENT 2
//#define ENOMEM 12
//#/define EACCES 13
//#define ENOTDIR 20
//#define ENFILE 23
//#define EMFILE 24
/**
* Provides directory and file functionality that are commanly used.
*
* @short Provide directory and file functionality.
*/
class STDriveOps: public STObjectController
{
private:
QString ReturnString;
STParserOps *ParserOps1;
STTime *Time1;
protected:
//
public:
/**
* Constructor
*/
STDriveOps();
/**
* Destructor
*/
~STDriveOps();
/**
* ReturnParts lets you define what information is retuned in the lists when
* @ref RecurseFiles is called.
*/
struct TReturnParts
{
bool IncludeDrive;
bool IncludePath;
bool IncludeFileName;
bool IncludeFileExtention;
bool IncludeFileSize;
bool IncludeFileDate;
bool IncludeFileAttibutes;
bool IncludePathSize;
bool IncludePathDate;
bool IncludeDirectoryAttributes;
bool IncludeFileAttributes;
};
TReturnParts ReturnParts;
/**
* SearchPeramiters lets you define what information is qualified to be retuned
* in the lists when @ref GetFiles is called.
*/
struct TSearchPeramiters
{
QString FileAndPathMatch,
FileAndPathAvoid,
FileMatch,
FileAvoid,
FileExtentionMatch,
FileExtentionAvoid,
PathMatch,
PathAvoid,
DriveMatch,
DriveAvoid;
int FileSizeMin,
FileSizeMax;
long FileMinDate,
FileMaxDate;
int FileAttributesMatch,
FileAttributesAvoid;
};
TSearchPeramiters SearchPeramiters;
/**
* Any directories created will used this value for permissions.
*
* Default is 777.
*/
int DefaultPermissions;
/**
* Any directories created will used this value for the owner.
*
* Default is nobody.
*/
QString DefaultOwner;
/**
* Any file I/O errors are handled here and out put a text description.
*/
void FileIOErrorCodes();
/**
* Any directories created will used this value for the group.
*
* Default is nobody.
*/
QString DefaultGroup;
/**
* Attempts to return the path part of a path to a file.
* The path does not have to exist, therefor if the given path to a file
* is only a path to a directory, the parent directory will be returned.
*/
QString ExtractPath(QString &ProvidedPathFile);
QString ExtractPath(const char *ProvidedPathFile);
/**
* Attempts to return the file part of a path and file.
* The path and file do not have to exist, therefor if the given path and file
* is only a path to a directory, the parent directory will be returned.
*/
QString ExtractFileName(QString &PathFileName);
QString ExtractFileName(const char *PathFileName);
/**
* Returns a double that is the number of days and fraction of a day accorning
* to @ref STTime::Now since the file was last modified.
*/
double GetFileMDate(QString &PathFileName);
double GetFileMDate(const char *PathFileName);
/**
* Returns true if a given file exists.
*/
bool FileExists(QString &PathFileName);
bool FileExists(const char *PathFileName);
/**
* Returns true if a given path exists.
*/
bool DirExists(QString &PathFileName);
bool DirExists(const char *PathFileName);
/**
* Tests every part in a given path and creats them if needed.
*/
bool MakePath(QString &PathToCreate);
/**
* Tests every part in a given path and creats them if needed.
*/
bool MakePath(const char *PathToCreate);
/**
* Recursivly enters sub directories form the current directory looking for
* files, all files found are placed in the string list. If LevelOfRecurtion = 0
* then the recursion will continue for as many deepths as the directories go or as far
* as the system memory will support. If LevelOfRecurtion > 0 then recursion will
* continue for as many sub-directory deepths as LevelOfRecurtion's value. The starting
* directory is has the level of 1. If LevelOfRecurtion = 1 then only files in the
* starting directory will be added to the list, no sub directories will be checked.
* If LevelOfRecurtion = 2 then the files in the starting directory and the files that
* are found imediatly in the sub-directories of the starting directory will be added to
* the list.
* @ref TReturnParts
*/
void RecurseFiles(STStringList *FilesStringList, int LevelOfRecurtion);
/**
* Works just like RecurseFiles(STStringList *,int) but lets you set the directory that
* you want to start searching from.
*/
void RecurseFiles(STStringList *FilesStringList, int LevelOfRecurtion, QString &DirectoryToStartIn);
void RecurseFiles(STStringList *FilesStringList, int LevelOfRecurtion, char *DirectoryToStartIn);
/**
* Recursivly enters sub directories form the current directory looking for
* directories, all directories found are placed in the string list. If LevelOfRecurtion = 0
* then the recursion will continue for as many deepths as the directories go or as far
* as the system memory will support. If LevelOfRecurtion > 0 then recursion will
* continue for as many sub-directory deepths as LevelOfRecurtion's value. The starting
* directory is has the level of 1. If LevelOfRecurtion = 1 then only directories in the
* starting directory will be added to the list, no sub directories contents will be checked.
* If LevelOfRecurtion = 2 then the directories in the starting directory and the directories that
* are found imediatly in the sub-directories of the starting directory will be added to
* the list.
*/
void RecursePath(STStringList *PathStringList, int LevelOfRecurtion);
/**
* Works just like RecursePath(STStringList *,int) but lets you set the directory that
* you want to start searching from.
*/
void RecursePath(STStringList *PathStringList, int LevelOfRecurtion, QString &DirectoryToStartIn);
void RecursePath(STStringList *PathStringList, int LevelOfRecurtion, char *DirectoryToStartIn);
/**
* Returns the name of the current directory that the application is in.
*
* Example:
*
* QString TempString;
* STDriveOps *DriveOps1;
*
* DriveOps1 = new STDriveOps();
* TempString = DriveOps1->GetDir();
* LineEdit1->setText(TempString);
* delete DriveOps1;
*
*/
QString GetDir();
/**
* Tries to find the full path to the parent dir of a given file or path.
*
* @li Things you can give it
* @li /
* @li ../ (and mutiples of)
* @li ../../../
* @li ./
* @li Aname/ (and mutiples of)
* @li Aname/Bname/
*
* @li Things you can not give it.
* @li .././
* @li ./../
* @li ..//Aname
* @li Aname/Bname/../Cname/
* @li Aname/Bname/./Cname/
* @li Some day I may add the smarts to detect these, but not now.
*/
QString GetParentDir(QString &ChildPath);
/**
* Fills a given list with name of directories in the current directory.
*
* Example:
*
* int ALoopCounter;
* QString OriginalDir;
* STStringList *Directories;
* STDriveOps *DriveOps1;
*
* Directories = new STStringList();
* DriveOps1 = new STDriveOps();
* OriginalDir = DriveOps1->GetDir();
* chdir("/");
*
* DriveOps1->GetDirectories(Directories);
* for(ALoopCounter=0;ALoopCounterCount();ALoopCounter++)
* {
* MultiLineEdit1->append(Directories->Item(ALoopCounter));
* }
* chdir(OriginalDir);
*
* delete Directories;
*/
void GetDirectories(STStringList *DirectoryList);
/**
* Fills a given list with name of directories in a spacific directory.
*
*/
void GetDirectories(STStringList *DirectoryList, QString &StartingDir);
/**
* Fills a given list with name of files in the current directory.
*
* @ref TSearchPeramiters
*
* Example:
*
* int ALoopCounter;
* QString OriginalDir;
* STStringList *TheFiles;
* STDriveOps *DriveOps1;
*
* TheFiles = new STStringList();
* DriveOps1 = new STDriveOps();
* OriginalDir = DriveOps1->GetDir();
* chdir("/");
*
* // Only look for *.txt files.
* DriveOps1->SearchPeramiters.FileMatch = "*.txt";
* DriveOps1->GetFiles(TheFiles);
* for(ALoopCounter=0;ALoopCounterCount();ALoopCounter++)
* {
* MultiLineEdit1->append(TheFiles->Item(ALoopCounter));
* }
* chdir(OriginalDir);
*
* delete TheFiles;
*/
void GetFiles(STStringList *FilesList);
/**
* Fills a given list with name of files in a spacific directory.
*
*/
void GetFiles(STStringList *FilesList, QString &StartingDir);
/**
* Attempts to delete a given file.
*/
int KillFile(QString &FileToDelete);
int KillFile(const char *FileToDelete);
/**
* Attempts to delete a given directroy and every thing in it.
*/
int KillDir(QString &FileToDelete);
int KillDir(const char *FileToDelete);
/**
* Returns the number of bytes in a given file.
*/
int FileSize(QString &FilePathName);
/**
*
*/
void ResetSearchPeramiters();
};
#endif // STDriveOps_included
Generated by: root on UtopiaPlanitia.Ept on Mon Dec 10 22:55:12 2001, using kdoc 2.0a53. |