EDT PDV SDK Documentation 6.1.0
edt_os_utils.h File Reference

(git 21fd03f, 2023-10-24)

#include "edt_types.h"
#include "edt_portability.h"
Include dependency graph for edt_os_utils.h:
This graph shows which files directly or indirectly include this file:

Functions

double edt_dtime (void)
 Return the time in seconds since the last call to edt_dtime. More...
 
double edt_timestamp (void)
 Gets the seconds + fractional seconds since the Epoch, OS independent. Uses system time; accuracy is OS dependent. More...
 
void edt_msleep (int msecs)
 Causes the process to sleep for the specified number of milliseconds. More...
 
void edt_usleep (int usecs)
 Causes process to sleep for specified number of microseconds. More...
 
void edt_free (void *ptr)
 Convenience routine to free the memory allocated with edt_alloc. More...
 
void * edt_alloc (size_t size)
 Convenience routine to allocate memory in a system-independent way. The buffer returned is page aligned. Uses VirtualAlloc on Windows NT systems, valloc on UNIX-based systems. More...
 
void edt_closedir (DIRHANDLE h)
 Cross platform function to close a directory handle. More...
 
DIRHANDLE edt_opendir (const char *dirname)
 Cross platform function to open a directory for reading. More...
 
int edt_readdir (DIRHANDLE h, char *name)
 Cross platform function to read the next directory entry. More...
 
void edt_correct_slashes (char *str)
 Change the slashes in str from forward to back or vice versa depending on whether it's Windows or Unix. More...
 
void edt_fwd_to_back (char *str)
 
void edt_back_to_fwd (char *str)
 
int edt_access (const char *fname, int perm)
 Determines file access, independent of operating system. More...
 

Detailed Description

Utility functions with OS-specific implementations.

Function Documentation

◆ edt_dtime()

double edt_dtime ( void  )

Return the time in seconds since the last call to edt_dtime.

Each time edt_dtime is called, it returns the time delta since the last time it was called. Therefore the first time edt_dtime is called in a process the delta may be meaningless. Time is in seconds and fractions of a second.

This call uses system time, which is system dependent and may be too coarse for some applications. For more accurate time stamping consider the IRIG option and an external IRIG timestamp source, available with some EDT boards.

Returns
delta time, as a double floating point
Here is the caller graph for this function:

◆ edt_timestamp()

double edt_timestamp ( void  )

Gets the seconds + fractional seconds since the Epoch, OS independent. Uses system time; accuracy is OS dependent.

Returns
The timestamp in seconds; a double value with tenths/hundredths/etc on the right of the decimal point.
Here is the caller graph for this function:

◆ edt_msleep()

void edt_msleep ( int  msecs)

Causes the process to sleep for the specified number of milliseconds.

Parameters
msecsThe number of milliseconds for the process to sleep.
Returns
0 on success, -1 on failure. If an error occurs, call #edt_perror to get the system error message.
Here is the caller graph for this function:

◆ edt_usleep()

void edt_usleep ( int  usecs)

Causes process to sleep for specified number of microseconds.

Parameters
usecsNumber of microseconds for process to sleep.
Returns
0 on success; -1 on error

◆ edt_free()

void edt_free ( void *  ptr)

Convenience routine to free the memory allocated with edt_alloc.

Parameters
ptrAddress of memory buffer to free.
Here is the caller graph for this function:

◆ edt_alloc()

void * edt_alloc ( size_t  size)

Convenience routine to allocate memory in a system-independent way. The buffer returned is page aligned. Uses VirtualAlloc on Windows NT systems, valloc on UNIX-based systems.

Parameters
sizeNumber of bytes of memory to allocate.
Returns
The address of the allocated memory, or NULL on error. If NULL, use #edt_perror to print the error.
Here is the caller graph for this function:

◆ edt_closedir()

void edt_closedir ( DIRHANDLE  h)

Cross platform function to close a directory handle.

Parameters
hOpen directory handle.

◆ edt_opendir()

DIRHANDLE edt_opendir ( const char *  dirname)

Cross platform function to open a directory for reading.

Parameters
dirnameThe name of the directory to open.
Returns
Directory handle upon success or NULL on failure.

◆ edt_readdir()

int edt_readdir ( DIRHANDLE  h,
char *  name 
)

Cross platform function to read the next directory entry.

Parameters
hA handle for the directory, returned by edt_opendir.
nameA pointer to a string into which the name of the next file in the directory will be written. The string must be allocated by the caller to at least 256 bytes.
Returns
h if entries remain or NULL if this is the last entry.

◆ edt_correct_slashes()

void edt_correct_slashes ( char *  str)

Change the slashes in str from forward to back or vice versa depending on whether it's Windows or Unix.

Parameters
strString to process.
Here is the call graph for this function:

◆ edt_fwd_to_back()

void edt_fwd_to_back ( char *  str)

fwd_to_back: for use by edt_correct_slashes

◆ edt_back_to_fwd()

void edt_back_to_fwd ( char *  str)

back_to_fwd: for use by edt_correct_slashes

Here is the caller graph for this function:

◆ edt_access()

int edt_access ( const char *  fname,
int  perm 
)

Determines file access, independent of operating system.

This a convenience routine that maps to access() on Unix/Linux systems and _access() on Windows systems.

Parameters
fnamePath name of file to check access permissions.
permPermission flag(s) to test for. See documentation for access() (Unix/Linux) or _access() (Windows) for valid values.
Returns
0 on success, -1 on failure

\Example

if(edt_access("file.ras", F_OK))
printf("Warning: overwriting file %s\n", "file.ras");
Here is the caller graph for this function: