Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

utils.cpp File Reference

Various utility functions. More...

#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/datetime.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include <wx/tokenzr.h>
#include <climits>
#include "utils.hpp"
#include "comdefs.hpp"
#include "dlgProgress.hpp"
#include "osdep.hpp"
#include "compat.hpp"

Include dependency graph for utils.cpp:

Include dependency graph

Go to the source code of this file.

Functions

int compareFileName (const wxString &fn1, const wxString &fn2)
 Compares two file names.

int FilesInSubdirectoriesCounterConverter (const double pc, const int mn, const int mx)
 Convert progress bar counter values.

void GetAllTokenCases (wxString token, wxArrayString &tk, size_t p)
 Get the given token with all the possible cases.

wxString getAppName (bool addVersion)
 Gets the application's name.

bool getFilesInSubdirectories (const wxArrayString &lFiles, wxArrayString &res, BytesDisplayer &filesSize, const wxString &matchPattern, unsigned int maxDepth)
 Find all the files in the subdirectories from a list of files and directories.

bool getFilesInSubdirectoriesRec (const wxArrayString &lFiles, wxArrayString &res, BytesDisplayer &filesSize, const wxArrayString &matchPatterns, const unsigned int depth, wxDateTime &lt, dlgProgress &dlgProgress, double cp, double cpMax)
 Find all the files in the subdirectories from a list of files and directories.

wxColour longTowxColour (long value)
 Convert a long value to a wxColour value.

void ToLower (wxString &s, size_t idx)
 Convert the specified character to the lower case.

void ToUpper (wxString &s, size_t idx)
 Convert the specified character to the upper case.

long wxColourToLong (const wxColour &value)
 Convert a wxColour value to a long value.


Detailed Description

Various utility functions.

Definition in file utils.cpp.


Function Documentation

int compareFileName const wxString &  fn1,
const wxString &  fn2
 

Compares two file names.

Under Windows the comparison is case insensitive.

Parameters:
fn1 First file name.
fn2 Second file name.
Returns:
A negative value if f1 < f2, a positive value if f1 > f2, 0 if f1 == f2.

Definition at line 76 of file utils.cpp.

Referenced by dlgFilesSelector::addFileNamesToListView(), dlgAddMatchFiles::addLineToComboBox(), dlgFilesSelector::addLineToComboBox(), removeFilesInListCompare(), and dlgFilesSelector::FilesListValidator::TransferToWindow().

int FilesInSubdirectoriesCounterConverter const double  pc,
const int  mn,
const int  mx
[static]
 

Convert progress bar counter values.

For getFilesInSubdirectories() and getFilesInSubdirectoriesRec() internal usage only.

Parameters:
pc Progress bar value.
mn Minimum value.
mx Maximal value.

Definition at line 100 of file utils.cpp.

Referenced by getFilesInSubdirectoriesRec().

void GetAllTokenCases wxString  token,
wxArrayString &  tk,
size_t  p
 

Get the given token with all the possible cases.

Result is added to tk.

Parameters:
token Token to get with all the possible cases.
tk Arary of string when the tokens will be added.
p Current position in the token (only for internal recursivity).

Definition at line 392 of file utils.cpp.

References ToLower(), and ToUpper().

Referenced by getFilesInSubdirectories(), and wxFileDialogFilterMaker::GetFilters().

wxString getAppName bool  addVersion  ) 
 

Gets the application's name.

Parameters:
addVersion If true, add the version number + special.
Returns:
The application's name.

Definition at line 293 of file utils.cpp.

References APP_MAJOR_VER, APP_MINOR_VER, APP_NAME, APP_SPECIAL, and APP_SUBVER.

Referenced by dlgAddMatchFiles::btnSaveListClick(), dlgAbout::createControls(), dlgConfigure::createControls(), CmdLineOptions::init(), CkSumsApp::OnInitCmdLine(), and MD5File::write().

bool getFilesInSubdirectories const wxArrayString &  lFiles,
wxArrayString &  res,
BytesDisplayer filesSize,
const wxString &  matchPattern,
unsigned int  maxDepth
 

Find all the files in the subdirectories from a list of files and directories.

A matching pattern can be speficied. Wildcards are * and ?. * subtitutes one or more characters, ? one character.
Matching patterns are separated by the ; character.
If no matching patterns are given, all the files will be matched.

The depth of recursion can be 0 for no limit, 1 for the given directories, 2 for the given directories and their subdirectories, etc...

Parameters:
lFiles List of files and directories to search into.
res Array of string where all the founded files will to stored. All files present in lFiles will be copied (but not the directories).
filesSize Will contains the total size of the parsed files.
matchPattern Optionnal matching pattern for files' names.
maxDepth Maximal depth of recursion.
Returns:
true on success, false on failure or if the user has canceled.

Definition at line 247 of file utils.cpp.

References GetAllTokenCases(), getFilesInSubdirectoriesRec(), dlgProgress::Update(), and UPDATE_PROGRESS_DLG.

bool getFilesInSubdirectoriesRec const wxArrayString &  lFiles,
wxArrayString &  res,
BytesDisplayer filesSize,
const wxArrayString &  matchPatterns,
const unsigned int  depth,
wxDateTime &  lt,
dlgProgress dlgProgress,
double  cp,
double  cpMax
[static]
 

Find all the files in the subdirectories from a list of files and directories.

For internal usage only.

Parameters:
lFiles List of files and directories to search into.
res Array of string where all the founded files will to stored. All files present in lFiles will be copied (but not the directories).
filesSize Will contains the total size of the parsed files.
matchPatterns Optionnal matching patterns for files' names.
depth Maximal depth of recursion.
lt Last time when the dialog has been updated.
dlgProgress Progress dialog.
cp Current position for the progress bar.
cpMax Maximal position for the progress bar.
Returns:
true on success, false on failure or if the user has canceled.

Definition at line 130 of file utils.cpp.

References FilesInSubdirectoriesCounterConverter(), dlgProgress::isPaused(), dlgProgress::Update(), UPDATE_PROGRESS_DLG, wxCGetFileLength, and wxCOff_t.

Referenced by getFilesInSubdirectories().

wxColour longTowxColour long  value  ) 
 

Convert a long value to a wxColour value.

Parameters:
value The value to convert.
Returns:
The value converted to a wxColour value.

Definition at line 336 of file utils.cpp.

Referenced by dlgResultsProgress::getColour().

void ToLower wxString &  s,
size_t  idx
 

Convert the specified character to the lower case.

Parameters:
s String that contains the character to lower.
idx Index in s of the character to lower.

Definition at line 353 of file utils.cpp.

Referenced by GetAllTokenCases().

void ToUpper wxString &  s,
size_t  idx
 

Convert the specified character to the upper case.

Parameters:
s String that contains the character to upper.
idx Index in s of the character to upper.

Definition at line 372 of file utils.cpp.

Referenced by GetAllTokenCases().

long wxColourToLong const wxColour &  value  ) 
 

Convert a wxColour value to a long value.

Parameters:
value The value to convert.
Returns:
The value converted to a long value.

Definition at line 318 of file utils.cpp.

Referenced by frmSums::itmToolsConfigureClick().


Generated on Sun May 30 13:38:02 2004 for wxChecksums by doxygen 1.3.7