Main Page   Modules   Data Structures   File List   Data Fields   Globals  

Miscellaneous library tools

Wrappers to various odd tools contained in the libdar C++ library. More...

File size tools

The main purpose of the infinint is the elimination of file and archive size limits.

As such, these functions provide minor assistance in wrapping system calls and string interpretation into the infinint infrastructure. Of the internal toolset in the libdar library, interfaces to the file size query and string parsing mechanism are provided.

#define DAR_TOOLS_SI_BASE   1000
 Base size of prefixes for SI system.

#define DAR_TOOLS_BIN_BASE   1024
 Base size of prefixes for Binary system.


Functions

NAMESPACE_LIBDAR_START dar_infinintdar_tools_get_extended_size (char *s, U_I base)
 Converts string containing an integer with size factor.

char * dar_tools_display_date (dar_infinint *date)
 Converts date in seconds to a human readable format.

char * dar_tools_string_justify_right (char *s, U_I min_size)
 Given a minimum text field size, justifies text to the right of that field.

char * dar_tools_string_justify_center (char *s, U_I min_size)
 Given a minimum text field size, justifies text to the centermost possible, expanding the field as neccessary.

char * dar_tools_string_justify_left (char *s, U_I min_size)
 Given a minimum text field size, justifies text to the leftmost possible, expanding the field as neccessary.

char * dar_tools_string_justify_right_truncate (char *s, U_I fixed_size)
 Given a fixed text field size, justifies text to the rightmost possible, truncating overflow from the right, making overlarge strings appear to be truncated after left justification.

char * dar_tools_string_justify_center_truncate (char *s, U_I fixed_size)
 Given a fixed text field size, justifies text to the centermost possible, truncating all data that does not fit in that size.

char * dar_tools_string_justify_left_truncate (char *s, U_I fixed_size)
 Given a fixed text field size, justifies text to the leftmost possible, truncating all data that does not fit in that size.

char * dar_tools_name_of_uid (U_16 uid)
 Obtains string name of integer user id.

char * dar_tools_name_of_gid (U_16 gid)
 Obtains string name of integer group id.

char * dar_tools_get_cwd ()
 Obtains string representation of current working directory.


Detailed Description

Wrappers to various odd tools contained in the libdar C++ library.

The tool collection of which these functions come from is composed mainly of backend file system access, system library smoothers, and data type handling. Much of the file system and system library functions are not relevant for this C binding and have thus been left out.

None of the functions found below are strictly neccessary for utilization of the library. Those that can be useful in other areas are generally available in other libraries.

In short, the functions found below should be used with caution, for there is no guarantee they will be retained in future versions of the C binding. (At any rate they will most likely be reorganized some time soon).


Function Documentation

char* dar_tools_display_date dar_infinint   date
 

Converts date in seconds to a human readable format.

NEEDS IMPROVEMENT NOTE: (1) What output format here? (2) What date format? Unix time?

Parameters:
date  Date in seconds.
Returns:
Human readable format.

Definition at line 77 of file tools.cpp.

char* dar_tools_get_cwd  
 

Obtains string representation of current working directory.

NEEDS IMPROVEMENT NOTE: (1) is this absolute path?

Definition at line 237 of file tools.cpp.

NAMESPACE_LIBDAR_START dar_infinint* dar_tools_get_extended_size char *    s,
U_I    base
 

Converts string containing an integer with size factor.

Base system is selectable. SI and binary constants are provided. Several size factors are allowed:


Where 'base' is either 1000 (SI) or 1024 (Binary)

(Supported)                                (Not supported)

Symbol   Deriv   SI     Bin    SI name    |  Binary name/prefix
                                          |  
k, K     base^1  10^3   2^10   kilobyte   |  (kibibyte - Ki)
M        base^2  10^6   2^20   megabyte   |  (mebibyte - Mi)
G        base^3  10^9   2^30   gigabyte   |  (gibibyte - Gi)
T        base^4  10^12  2^40   terabyte   |  (tebibyte - Ti)
P        base^5  10^15  2^50   petabyte   |  (pebibyte - Pi)
E        base^6  10^18  2^60   exabyte    |  (exbibyte - Ei)
Z        base^7  10^21  2^70   zettabyte  |  (zebibyte - Zi)
Y        base^8  10^24  2^80   yottabyte  |  (yobibyte - Yi)

Parameters:
base  Base system size. See above chart for conversion values.
s  String representing prefixed integer.
Returns:
Value of the given string in bytes.

Definition at line 50 of file tools.cpp.

char* dar_tools_name_of_gid U_16    gid
 

Obtains string name of integer group id.

Returns null if group name does not exist.

Definition at line 226 of file tools.cpp.

char* dar_tools_name_of_uid U_16    uid
 

Obtains string name of integer user id.

Returns null if user name does not exist.

Definition at line 209 of file tools.cpp.

char* dar_tools_string_justify_center_truncate char *    s,
U_I    fixed_size
 

Given a fixed text field size, justifies text to the centermost possible, truncating all data that does not fit in that size.

All truncations will occur from the rightmost of the text, making overlarge strings appear to be truncated after left justification.

Definition at line 174 of file tools.cpp.

char* dar_tools_string_justify_left char *    s,
U_I    min_size
 

Given a minimum text field size, justifies text to the leftmost possible, expanding the field as neccessary.

This is the same as simply increasing a string to the desired length if currently shorter than that length.

Definition at line 142 of file tools.cpp.

char* dar_tools_string_justify_left_truncate char *    s,
U_I    fixed_size
 

Given a fixed text field size, justifies text to the leftmost possible, truncating all data that does not fit in that size.

For too small strings, this is the same as simply adding blank space to the end. For too long strings, this is the same as simply clipping the end.

Definition at line 192 of file tools.cpp.

char* dar_tools_string_justify_right char *    s,
U_I    min_size
 

Given a minimum text field size, justifies text to the right of that field.

If the input string length is longer than the minimum size, the text will be pressed against the left and the field size will be expanded to fit the entire string.

This is a wrapper for tools_addspacebefore in libdar. This renaming allows for increased clarity when symmetricizing the function set (justify left, center, truncate, etc).

Parameters:
s  String data.
min_size  Resultant string will be no shorter than this length, with string justified to the right of the field.
Returns:
Final output string equal to or larger than the requested minimum size.

Definition at line 109 of file tools.cpp.