Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

ktool.h File Reference

Some useful functions, or not. More...

#include "ktypes.h"
#include "KList.h"
#include "KStrList.h"

Defines

#define k_min(a, b)   ((a) <= (b) ? (a) : (b))
 Determines the minimum number between two integral numbers.
#define k_max(a, b)   ((a) >= (b) ? (a) : (b))
 Determines the maximum number between two integral numbers.
#define kdouble_isequal(v1, v2, eps)   (k_fabs ((v1) - (v2)) < (eps))
 Compares two floating point numbers regarding an epsilon value.
#define K_RAND_MAX   0x7fff
 Represents the maximum number returned by k_rand_i.
#define k_getDirFiles(sDirPath)   _k_getDirFiles (sDirPath, knull, __K_FILE__, __K_LINE__)
 Returns the file list contained in the specified directory. Works only onto Windows systems. Returns the complete file names and directories except . and .. Warning! The returned KStrList structure must be deleted after using.
#define k_getDirFilteredFiles(sDirPath, sEndsWith)   _k_getDirFiles (sDirPath, sEndsWith, __K_FILE__, __K_LINE__)
 Returns the file list contained in the specified directory. Works only onto Windows systems. Returns the complete file names and directories except . and .. Warning! The returned KStrList structure must be deleted after using.

Functions

KTL_API void k_sleep (KInt sec)
 Delays the current thread for a specified amount of time in second.
KTL_API void k_usleep (KUInt32 usec)
 Delays the current thread for a specified amount of time in micro second.
KTL_API KInt64 k_find_index (KCPtr *parray, KCPtr data, KInt64 n)
 Returns index of the data stored in an array.
KTL_API KInt k_rand_i ()
 Returns a random integral number between 0 and K_RAND_MAX.
KTL_API void k_srand (KUInt t)
 Initialization of k_rand_i.
KTL_API void k_rand_init ()
 Initialization of the random functions.
KTL_API KInt64 k_rand_i64 (const KInt64 max)
 Returns a 64 bits random integral number between 0 and the parameter.
KTL_API KDouble k_rand ()
 Returns a random floating point number between 0 and 1.
KTL_API KString k_rand_string (const KInt64 len)
 Returns a random string with a random length. The random characters can be upper/lower-case or numbers between 0 and 9.
KTL_API KChar k_rand_char ()
 Returns a random character. The random character can be upper/lower-case or a number between 0 and 9.
KTL_API KString k_getFileName (KCString sFilePath)
 Returns the file name of a file (without extension).
KTL_API KString k_getDirPath (KCString sFilePath)
 Returns the directory path name of a file.
KTL_API KString k_getFileExt (KCString sFilePath)
 Returns the file extension of a file (without name).
KTL_API KString k_getCompleteFile (KCString sPath)
 Returns the complete file name (name + extension).
KTL_API KString k_makePath (KCString sDirPath, KCString sFileName)
 Makes a file path by adding the directory path and the file name.
KTL_API KBool k_cleanPath (KString sPath)
 Replaces the character / by the characters \ in the path file.
KTL_API KStrList_k_getDirFiles (KCString sCInDirPath, KCString sEndsWith, KString sFile, KInt32 iLine)
 Returns the file list contained in the specified directory. Works only onto Windows systems. Returns the complete file names and directories except . and .. Warning! The returned KStrList structure must be deleted after using.
KTL_API void k_deleteFileList (KList **plFileList)
 Deletes a list of file names.


Detailed Description

Some useful functions, or not.

Version:
KToolLib-1.0
Author:
Fabien Gallot
Date:
18/03/2009
Note:
Copyright © 2008-2010 iKlax Media SAS (www.iklaxmedia.com). All rights reserved.

Define Documentation

#define k_getDirFiles sDirPath   )     _k_getDirFiles (sDirPath, knull, __K_FILE__, __K_LINE__)
 

Returns the file list contained in the specified directory. Works only onto Windows systems. Returns the complete file names and directories except . and .. Warning! The returned KStrList structure must be deleted after using.

Parameters:
sDirPath the path to be detailed
Returns:
a pointer to a KStrList structure if successful otherwise knull

#define k_getDirFilteredFiles sDirPath,
sEndsWith   )     _k_getDirFiles (sDirPath, sEndsWith, __K_FILE__, __K_LINE__)
 

Returns the file list contained in the specified directory. Works only onto Windows systems. Returns the complete file names and directories except . and .. Warning! The returned KStrList structure must be deleted after using.

Parameters:
sDirPath the path to be detailed
sEndsWith ??
Returns:
a pointer to a KStrList structure if successful otherwise knull

#define k_max a,
 )     ((a) >= (b) ? (a) : (b))
 

Determines the maximum number between two integral numbers.

Parameters:
a the first integral number
b the second integral number
Returns:
the maximum number

#define k_min a,
 )     ((a) <= (b) ? (a) : (b))
 

Determines the minimum number between two integral numbers.

Parameters:
a the first integral number
b the second integral number
Returns:
the minimum number

#define kdouble_isequal v1,
v2,
eps   )     (k_fabs ((v1) - (v2)) < (eps))
 

Compares two floating point numbers regarding an epsilon value.

Parameters:
v1 the first floating point number
v2 the second floating point number
eps the epsilon value
Returns:
the result of the compare


Function Documentation

KTL_API KStrList* _k_getDirFiles KCString  sCInDirPath,
KCString  sEndsWith,
KString  sFile,
KInt32  iLine
 

Returns the file list contained in the specified directory. Works only onto Windows systems. Returns the complete file names and directories except . and .. Warning! The returned KStrList structure must be deleted after using.

Parameters:
sCInDirPath the path to be detailed
sEndsWith ??
sFile the file name where this function is called
iLine the line number where this function is called
Returns:
a pointer to a KStrList structure if successful otherwise knull

KTL_API KBool k_cleanPath KString  sPath  ) 
 

Replaces the character / by the characters \ in the path file.

Parameters:
sPath the path to be modified
Returns:
ktrue if successful otherwise kfalse

KTL_API void k_deleteFileList KList **  plFileList  ) 
 

Deletes a list of file names.

Parameters:
plFileList the pointers to the KList structure to be deleted

KTL_API KInt64 k_find_index KCPtr parray,
KCPtr  data,
KInt64  n
 

Returns index of the data stored in an array.

Parameters:
parray the array
data the data
n the size of the array
Returns:
the index if successful otherwise -1

KTL_API KString k_getCompleteFile KCString  sPath  ) 
 

Returns the complete file name (name + extension).

Parameters:
sPath the file path
Returns:
the complete file name if successful otherwise knull

KTL_API KString k_getDirPath KCString  sFilePath  ) 
 

Returns the directory path name of a file.

Parameters:
sFilePath the file path
Returns:
the directory path if successful otherwise knull

KTL_API KString k_getFileExt KCString  sFilePath  ) 
 

Returns the file extension of a file (without name).

Parameters:
sFilePath the file path
Returns:
the file extension if successful otherwise knull

KTL_API KString k_getFileName KCString  sFilePath  ) 
 

Returns the file name of a file (without extension).

Parameters:
sFilePath the file path
Returns:
the file name if successful otherwise knull

KTL_API KString k_makePath KCString  sDirPath,
KCString  sFileName
 

Makes a file path by adding the directory path and the file name.

Parameters:
sDirPath the directory path
sFileName the file name
Returns:
the file path if successful otherwise knull

KTL_API KDouble k_rand  ) 
 

Returns a random floating point number between 0 and 1.

Returns:
the random floating point number

KTL_API KChar k_rand_char  ) 
 

Returns a random character. The random character can be upper/lower-case or a number between 0 and 9.

Returns:
the random character

KTL_API KInt k_rand_i  ) 
 

Returns a random integral number between 0 and K_RAND_MAX.

Returns:
the random integral number

KTL_API KInt64 k_rand_i64 const KInt64  max  ) 
 

Returns a 64 bits random integral number between 0 and the parameter.

Parameters:
max the maximum number
Returns:
the 64 bits random integral number

KTL_API KString k_rand_string const KInt64  len  ) 
 

Returns a random string with a random length. The random characters can be upper/lower-case or numbers between 0 and 9.

Parameters:
len the maximum length of the random string
Returns:
the random string

KTL_API void k_sleep KInt  sec  ) 
 

Delays the current thread for a specified amount of time in second.

Parameters:
sec the amount of time in second

KTL_API void k_srand KUInt  t  ) 
 

Initialization of k_rand_i.

Parameters:
t ??

KTL_API void k_usleep KUInt32  usec  ) 
 

Delays the current thread for a specified amount of time in micro second.

Parameters:
usec the amount of time in micro-second


Generated on Tue Mar 9 10:49:30 2010 for iKlax Tools Library (KToolLib) by doxygen 1.3.8