Main Page | Modules | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

hyfile.c File Reference


Detailed Description

file

#include <windows.h>
#include <sys/stat.h>
#include <time.h>
#include "hyport.h"
#include "portpriv.h"
#include "hystdarg.h"
#include "portnls.h"
#include "ut_hyprt.h"

Functions

I_32 VMCALL hyfile_attr (struct HyPortLibrary *portLibrary, const char *path)
 Determine whether path is a file or directory.
I_32 VMCALL hyfile_close (struct HyPortLibrary *portLibrary, IDATA fd)
 Closes a file descriptor.
const char *VMCALL hyfile_error_message (struct HyPortLibrary *portLibrary)
 Return an error message describing the last OS error that occurred.
void VMCALL hyfile_findclose (struct HyPortLibrary *portLibrary, UDATA findhandle)
 Close the handle returned from hyfile_findfirst.
UDATA VMCALL hyfile_findfirst (struct HyPortLibrary *portLibrary, const char *path, char *resultbuf)
 Find the first occurrence of a file identified by path.
I_32 VMCALL hyfile_findnext (struct HyPortLibrary *portLibrary, UDATA findhandle, char *resultbuf)
 Find the next filename and path matching a given handle.
I_64 VMCALL hyfile_lastmod (struct HyPortLibrary *portLibrary, const char *path)
 Return the last modification time of the file path in seconds.
I_64 VMCALL hyfile_length (struct HyPortLibrary *portLibrary, const char *path)
 Answer the length in bytes of the file.
I_32 VMCALL hyfile_mkdir (struct HyPortLibrary *portLibrary, const char *path)
 Create a directory.
I_32 VMCALL hyfile_move (struct HyPortLibrary *portLibrary, const char *pathExist, const char *pathNew)
 Move the file pathExist to a new name pathNew.
IDATA VMCALL hyfile_open (struct HyPortLibrary *portLibrary, const char *path, I_32 flags, I_32 mode)
 Convert a pathname into a file descriptor.
IDATA VMCALL hyfile_read (struct HyPortLibrary *portLibrary, IDATA fd, void *buf, IDATA nbytes)
 Read bytes from a file descriptor into a user provided buffer.
I_64 VMCALL hyfile_seek (struct HyPortLibrary *portLibrary, IDATA fd, I_64 offset, I_32 whence)
 Repositions the offset of the file descriptor to a given offset as per directive whence.
void VMCALL hyfile_shutdown (struct HyPortLibrary *portLibrary)
 PortLibrary shutdown.
I_32 VMCALL hyfile_startup (struct HyPortLibrary *portLibrary)
 PortLibrary startup.
I_32 VMCALL hyfile_sync (struct HyPortLibrary *portLibrary, IDATA fd)
 Synchronize a file's state with the state on disk.
I_32 VMCALL hyfile_unlink (struct HyPortLibrary *portLibrary, const char *path)
 Remove a file from the file system.
I_32 VMCALL hyfile_unlinkdir (struct HyPortLibrary *portLibrary, const char *path)
 Remove the trailing directory of the path.
void VMCALL hyfile_vprintf (struct HyPortLibrary *portLibrary, IDATA fd, const char *format, va_list args)
 Write to a file.
IDATA VMCALL hyfile_write (struct HyPortLibrary *portLibrary, IDATA fd, void *buf, IDATA nbytes)
 Write to a file.
void VMCALL hyfile_printf (struct HyPortLibrary *portLibrary, IDATA fd, const char *format,...)
 Write to a file.
I_32 VMCALL hyfile_set_length (struct HyPortLibrary *portLibrary, IDATA fd, I_64 newLength)
 Set the length of a file to a specified value.


Function Documentation

I_32 VMCALL hyfile_attr struct HyPortLibrary portLibrary,
const char *  path
 

Determine whether path is a file or directory.

Parameters:
[in] portLibrary The port library
[in] path file/path name being queried.
Returns:
EslsFile if a file, EslsDir if a directory, negative portable error code on failure.

I_32 VMCALL hyfile_close struct HyPortLibrary portLibrary,
IDATA  fd
 

Closes a file descriptor.

Parameters:
[in] portLibrary The port library
[in] fd The file descriptor.
Returns:
0 on success, -1 on failure.

const char* VMCALL hyfile_error_message struct HyPortLibrary portLibrary  ) 
 

Return an error message describing the last OS error that occurred.

The last error returned is not thread safe, it may not be related to the operation that failed for this thread.

Parameters:
[in] portLibrary The port library
Returns:
error message describing the last OS error, may return NULL.

void VMCALL hyfile_findclose struct HyPortLibrary portLibrary,
UDATA  findhandle
 

Close the handle returned from hyfile_findfirst.

Parameters:
[in] portLibrary The port library
[in] findhandle Handle returned from hyfile_findfirst.

UDATA VMCALL hyfile_findfirst struct HyPortLibrary portLibrary,
const char *  path,
char *  resultbuf
 

Find the first occurrence of a file identified by path.

Answers a handle to be used in subsequent calls to hyfile_findnext and hyfile_findclose.

Parameters:
[in] portLibrary The port library
[in] path file/path name being queried.
[out] resultbuf filename and path matching path.
Returns:
valid handle on success, -1 on failure.

I_32 VMCALL hyfile_findnext struct HyPortLibrary portLibrary,
UDATA  findhandle,
char *  resultbuf
 

Find the next filename and path matching a given handle.

Parameters:
[in] portLibrary The port library
[in] findhandle handle returned from hyfile_findfirst.
[out] resultbuf next filename and path matching findhandle.
Returns:
0 on success, -1 on failure or if no matching entries.

I_64 VMCALL hyfile_lastmod struct HyPortLibrary portLibrary,
const char *  path
 

Return the last modification time of the file path in seconds.

Parameters:
[in] portLibrary The port library
[in] path file/path name being queried.
Returns:
last modification time on success, -1 on failure.

I_64 VMCALL hyfile_length struct HyPortLibrary portLibrary,
const char *  path
 

Answer the length in bytes of the file.

Parameters:
[in] portLibrary The port library
[in] path file/path name being queried.
Returns:
Length in bytes of the file on success, negative portable error code on failure

I_32 VMCALL hyfile_mkdir struct HyPortLibrary portLibrary,
const char *  path
 

Create a directory.

Parameters:
[in] portLibrary The port library
[in] path Directory to be created.
Returns:
0 on success, -1 on failure.
Note:
Assumes all components of path up to the last directory already exist.

I_32 VMCALL hyfile_move struct HyPortLibrary portLibrary,
const char *  pathExist,
const char *  pathNew
 

Move the file pathExist to a new name pathNew.

Parameters:
[in] portLibrary The port library
[in] pathExist The existing file name.
[in] pathNew The new file name.
Returns:
0 on success, -1 on failure.

IDATA VMCALL hyfile_open struct HyPortLibrary portLibrary,
const char *  path,
I_32  flags,
I_32  mode
 

Convert a pathname into a file descriptor.

Parameters:
[in] portLibrary The port library
[in] path Name of the file to be opened.
[in] flags Portable file read/write attributes.
[in] mode Platform file permissions.
Returns:
The file descriptor of the newly opened file, -1 on failure.

void VMCALL hyfile_printf struct HyPortLibrary portLibrary,
IDATA  fd,
const char *  format,
  ...
 

Write to a file.

Writes formatted output to the file referenced by the file descriptor.

Parameters:
[in] portLibrary The port library
[in] fd File descriptor to write to
[in] format The format string to be output.
[in] ... arguments for format.

IDATA VMCALL hyfile_read struct HyPortLibrary portLibrary,
IDATA  fd,
void *  buf,
IDATA  nbytes
 

Read bytes from a file descriptor into a user provided buffer.

Parameters:
[in] portLibrary The port library
[in] fd The file descriptor.
[in,out] buf Buffer to read into.
[in] nbytes Size of buffer.
Returns:
The number of bytes read, or -1 on failure.

I_64 VMCALL hyfile_seek struct HyPortLibrary portLibrary,
IDATA  fd,
I_64  offset,
I_32  whence
 

Repositions the offset of the file descriptor to a given offset as per directive whence.

Parameters:
[in] portLibrary The port library
[in] fd The file descriptor.
[in] offset The offset in the file to position to.
[in] whence Portable constant describing how to apply the offset.
Returns:
The resulting offset on success, -1 on failure.
Note:
whence is one of HySeekSet (seek from beginning of file), HySeekCur (seek from current file pointer) or HySeekEnd (seek backwards from end of file).

I_32 VMCALL hyfile_set_length struct HyPortLibrary portLibrary,
IDATA  fd,
I_64  newLength
 

Set the length of a file to a specified value.

Parameters:
[in] portLibrary The port library
[in] fd The file descriptor.
[in] newLength Length to be set
Returns:
0 on success, negative portable error code on failure

void VMCALL hyfile_shutdown struct HyPortLibrary portLibrary  ) 
 

PortLibrary shutdown.

This function is called during shutdown of the portLibrary. Any resources that were created by hyfile_startup should be destroyed here.

Parameters:
[in] portLibrary The port library
Note:
Most implementations will be empty.

I_32 VMCALL hyfile_startup struct HyPortLibrary portLibrary  ) 
 

PortLibrary startup.

This function is called during startup of the portLibrary. Any resources that are required for the file operations may be created here. All resources created here should be destroyed in hyfile_shutdown.

Parameters:
[in] portLibrary The port library
Returns:
0 on success, negative error code on failure. Error code values returned are
  • HYPORT_ERROR_STARTUP_FILE
Note:
Most implementations will simply return success.

I_32 VMCALL hyfile_sync struct HyPortLibrary portLibrary,
IDATA  fd
 

Synchronize a file's state with the state on disk.

Parameters:
[in] portLibrary The port library
[in] fd The file descriptor.
Returns:
0 on success, -1 on failure.

I_32 VMCALL hyfile_unlink struct HyPortLibrary portLibrary,
const char *  path
 

Remove a file from the file system.

Parameters:
[in] portLibrary The port library
[in] path file/path name to remove.
Returns:
0 on success, -1 on failure.

I_32 VMCALL hyfile_unlinkdir struct HyPortLibrary portLibrary,
const char *  path
 

Remove the trailing directory of the path.

If the path is a symbolic link to a directory, remove the symbolic link.

Parameters:
[in] portLibrary The port library
[in] path directory name being removed.
Returns:
0 on success, -1 on failure.

void VMCALL hyfile_vprintf struct HyPortLibrary portLibrary,
IDATA  fd,
const char *  format,
va_list  args
 

Write to a file.

Writes formatted output to the file referenced by the file descriptor.

Parameters:
[in] portLibrary The port library
[in] fd File descriptor to write.
[in] format The format String.
[in] args Variable argument list.

IDATA VMCALL hyfile_write struct HyPortLibrary portLibrary,
IDATA  fd,
void *  buf,
IDATA  nbytes
 

Write to a file.

Writes up to nbytes from the provided buffer to the file referenced by the file descriptor.

Parameters:
[in] portLibrary The port library
[in] fd File descriptor to write.
[in] buf Buffer to be written.
[in] nbytes Size of buffer.
Returns:
Number of bytes written on success, -1 on failure.


(c) Copyright 2005 The Apache Software Foundation or its licensors, as applicable.