SB SDK 1.11
Folder

Folders management. More...

Collaboration diagram for Folder:

Data Structures

struct  sb_t_file
 Defines the single file. More...
 
struct  sb_t_folder
 defines the list of the file in a folder. More...
 

Functions

sb_t_err sb_folder_load (sb_t_folder **const f, const char *const path, const char *const ext, int sort, int verbosity)
 Creates the list of the name of the files in a specified folder. More...
 
sb_t_err sb_folder_destroy (sb_t_folder **folder)
 Frees all the resources of the sb_t_folder structure. More...
 
sb_t_err sb_folder_erase (sb_t_folder *folder, int index)
 Removes the file with the specified index from the list. More...
 
sb_t_err sb_folder_create (const char *const path)
 Creates the folder with the specified path. More...
 
sb_t_err sb_folder_remove (const char *const path)
 Deletes a folder and all the files and subfolder contained. More...
 
sb_t_err sb_folder_exist (const char *const path, int *const exist)
 Checks if the folder with the specified path exists. More...
 
sb_t_err sb_file_extract_name (const char *const full, int with_ext, char *const name, int name_size)
 Extracts the file name from the full file path. More...
 
sb_t_err sb_file_extract_folder (const char *const full, char *const folderpath, int folderpath_size)
 Extracts the folder path from the full file path. More...
 
sb_t_err sb_folder_filter_images (sb_t_folder *const folder, SB_HANDLE module, sb_t_image_info_type image_info_type)
 Filters images by project and type. More...
 

Detailed Description

Folders management.

Function Documentation

◆ sb_file_extract_folder()

sb_t_err sb_file_extract_folder ( const char *const  full,
char *const  folderpath,
int  folderpath_size 
)

Extracts the folder path from the full file path.

Parameters
[in]fullFull file path.
[out]folderpathThe folder path extracted.
[in]folderpath_sizeThe size, in bytes, of the string folderpath.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_file_extract_name()

sb_t_err sb_file_extract_name ( const char *const  full,
int  with_ext,
char *const  name,
int  name_size 
)

Extracts the file name from the full file path.

Parameters
[in]fullFull file path.
[in]with_extIf the value is different from 0 the file name includes the extension, otherwise not.
[out]nameThe file name without path.
[in]name_sizeThe size in bytes of the string name.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_folder_create()

sb_t_err sb_folder_create ( const char *const  path)

Creates the folder with the specified path.

Parameters
[in]pathPath to be created.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_folder_destroy()

sb_t_err sb_folder_destroy ( sb_t_folder **  folder)

Frees all the resources of the sb_t_folder structure.

Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_folder_erase()

sb_t_err sb_folder_erase ( sb_t_folder folder,
int  index 
)

Removes the file with the specified index from the list.

Parameters
[in]folderPointer to the folder.
[in]indexIndex of the file to remove from the list
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_folder_exist()

sb_t_err sb_folder_exist ( const char *const  path,
int *const  exist 
)

Checks if the folder with the specified path exists.

Parameters
[in]pathPath to be verified.
[out]existThe functions sets a value different from 0 if the path exists.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_folder_filter_images()

sb_t_err sb_folder_filter_images ( sb_t_folder *const  folder,
SB_HANDLE  module,
sb_t_image_info_type  image_info_type 
)

Filters images by project and type.

Parameters
folderPointer to the folder structure
moduleHandle of the project
image_info_typeType of images that need to be kept:
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.

◆ sb_folder_load()

sb_t_err sb_folder_load ( sb_t_folder **const  f,
const char *const  path,
const char *const  ext,
int  sort,
int  verbosity 
)

Creates the list of the name of the files in a specified folder.

Parameters
[out]fPointer to the folder structure
[in]pathName of the folder
[in]extExtensions of the files. It is possible to concatenate multiple extensions separated by the SB_DELIMITER character, for example "pgm;ppm;bmp". You can use "*" to load all the files.
[in]sortIf the value is different from 0 the list of files is sorted in a lexiconic way.
[in]verbosityVerbosity of the message. Set to 0 to disable all the messages.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.
See also
sb_folder_destroy

◆ sb_folder_remove()

sb_t_err sb_folder_remove ( const char *const  path)

Deletes a folder and all the files and subfolder contained.

Parameters
[in]pathPath to be deleted.
Returns
If successful, returns SB_ERR_NONE. Otherwise, it returns an error code sb_t_err.