S2OPC OPCUA Toolkit
Typedefs | Enumerations | Functions
sopc_filesystem.h File Reference

A platform independent API for file system operations. More...

#include <stdio.h>
#include <stdlib.h>
#include "sopc_array.h"

Go to the source code of this file.

Typedefs

typedef struct SOPC_FileSystem_Dir SOPC_FileSystem_Dir
 

Enumerations

enum  SOPC_FileSystem_CreationResult {
  SOPC_FileSystem_Creation_OK = 0, SOPC_FileSystem_Creation_Error_PathAlreadyExists, SOPC_FileSystem_Creation_Error_PathPrefixInvalid, SOPC_FileSystem_Creation_Error_PathResolutionIssue,
  SOPC_FileSystem_Creation_Error_PathPermisionDenied, SOPC_FileSystem_Creation_Error_UnknownIssue
}
 
enum  SOPC_FileSystem_RemoveResult {
  SOPC_FileSystem_Remove_OK = 0, SOPC_FileSystem_Remove_Error_PathNotEmpty, SOPC_FileSystem_Remove_Error_PathInvalid, SOPC_FileSystem_Remove_Error_PathPermisionDenied,
  SOPC_FileSystem_Remove_Error_UnknownIssue
}
 
enum  SOPC_FileSystem_GetDirResult { SOPC_FileSystem_GetDir_OK = 0, SOPC_FileSystem_GetDir_Error_InvalidParameters, SOPC_FileSystem_GetDir_Error_PathInvalid, SOPC_FileSystem_GetDir_Error_UnknownIssue }
 

Functions

SOPC_FileSystem_CreationResult SOPC_FileSystem_mkdir (const char *directoryPath)
 Request to create a directory with the given path in the file system. Only the last item of the path can be created, the path prefix shall exist. More...
 
SOPC_FileSystem_RemoveResult SOPC_FileSystem_rmdir (const char *directoryPath)
 Request to delete a directory with the given path in the file system. Only empty directory can be deleted. More...
 
SOPC_FileSystem_GetDirResult SOPC_FileSystem_GetDirFilePaths (const char *directoryPath, SOPC_Array **ppFilePaths)
 Request to list all the file paths of a directory with the given path in the file system. More...
 
FILE * SOPC_FileSystem_fmemopen (void *buf, size_t size, const char *opentype)
 Simulates a file open using an memory buffer rather than an actual file. refer to "fmemopen" linux manpage for precise specification. More...
 

Detailed Description

A platform independent API for file system operations.

Typedef Documentation

◆ SOPC_FileSystem_Dir

Enumeration Type Documentation

◆ SOPC_FileSystem_CreationResult

Enumerator
SOPC_FileSystem_Creation_OK 
SOPC_FileSystem_Creation_Error_PathAlreadyExists 
SOPC_FileSystem_Creation_Error_PathPrefixInvalid 
SOPC_FileSystem_Creation_Error_PathResolutionIssue 
SOPC_FileSystem_Creation_Error_PathPermisionDenied 
SOPC_FileSystem_Creation_Error_UnknownIssue 

◆ SOPC_FileSystem_RemoveResult

Enumerator
SOPC_FileSystem_Remove_OK 
SOPC_FileSystem_Remove_Error_PathNotEmpty 
SOPC_FileSystem_Remove_Error_PathInvalid 
SOPC_FileSystem_Remove_Error_PathPermisionDenied 
SOPC_FileSystem_Remove_Error_UnknownIssue 

◆ SOPC_FileSystem_GetDirResult

Enumerator
SOPC_FileSystem_GetDir_OK 
SOPC_FileSystem_GetDir_Error_InvalidParameters 
SOPC_FileSystem_GetDir_Error_PathInvalid 
SOPC_FileSystem_GetDir_Error_UnknownIssue 

Function Documentation

◆ SOPC_FileSystem_mkdir()

SOPC_FileSystem_CreationResult SOPC_FileSystem_mkdir ( const char *  directoryPath)

Request to create a directory with the given path in the file system. Only the last item of the path can be created, the path prefix shall exist.

Parameters
directoryPathThe directory path for which last item (regarding path delimiter) is the directory to create. Path delimiter is still dependent on O.S. but '/' path delimiter should be supported for relative paths.
Returns
SOPC_Creation_OK if directory creation succeeded or SOPC_Error_* value in other cases

◆ SOPC_FileSystem_rmdir()

SOPC_FileSystem_RemoveResult SOPC_FileSystem_rmdir ( const char *  directoryPath)

Request to delete a directory with the given path in the file system. Only empty directory can be deleted.

Parameters
directoryPathThe directory path in which last item (regarding path delimiter) is the directory to remove. Path delimiter is still dependent on O.S. but '/' path delimiter should be supported for relative paths.
Returns
SOPC_Remove_OK if directory creation succeeded or SOPC_Error_* value in other cases

◆ SOPC_FileSystem_GetDirFilePaths()

SOPC_FileSystem_GetDirResult SOPC_FileSystem_GetDirFilePaths ( const char *  directoryPath,
SOPC_Array **  ppFilePaths 
)

Request to list all the file paths of a directory with the given path in the file system.

Parameters
directoryPathThe directory path in which last item (regarding path delimiter) is the directory to read. Path delimiter is still dependent on O.S. but '/' path delimiter should be supported for relative paths.
ppFilePathsA newly allocated array of file paths (list of NULL terminated C string). You should free it with SOPC_Array_Delete.
Note
In case of error, ppFilePaths is set to NULL.
Returns
SOPC_ReadDir_OK if directory read succeeded or SOPC_Error_* value in other cases.

◆ SOPC_FileSystem_fmemopen()

FILE* SOPC_FileSystem_fmemopen ( void *  buf,
size_t  size,
const char *  opentype 
)

Simulates a file open using an memory buffer rather than an actual file. refer to "fmemopen" linux manpage for precise specification.

Parameters
bufNon-NULL pointer to the in/out buffer
sizeThe size of the buf
opentypeThe file mode: with the same convention as usual "fopen".
Warning
TODO This feature is only available on LINUX implementation. A Rework of the API might be needed for full portability.