Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
filesystem.h
Go to the documentation of this file.
1
11#ifndef FILESYSTEM_H
12#define FILESYSTEM_H
13
14#include <wireshark.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/*
21 * Default profile name.
22 */
23#define DEFAULT_PROFILE "Default"
24
37WS_DLL_PUBLIC char *configuration_init(const char *arg0, const char* app_flavor_lower);
38
47WS_DLL_PUBLIC const char *get_progfile_dir(void);
48
64WS_DLL_PUBLIC char *get_executable_path(const char *filename);
65
76WS_DLL_PUBLIC const char *get_plugins_dir(const char* app_env_var_prefix);
77
87WS_DLL_PUBLIC const char *get_plugins_dir_with_version(const char* app_env_var_prefix);
88
97WS_DLL_PUBLIC const char *get_plugins_pers_dir(const char* app_env_var_prefix);
98
108WS_DLL_PUBLIC const char *get_plugins_pers_dir_with_version(const char* app_env_var_prefix);
109
121WS_DLL_PUBLIC const char *get_extcap_dir(const char* app_env_var_prefix, const char* dir_extcap);
122
132WS_DLL_PUBLIC const char *get_extcap_pers_dir(const char* app_env_var_prefix);
133
142WS_DLL_PUBLIC bool running_in_build_directory(void);
143
153WS_DLL_PUBLIC const char *get_datafile_dir(const char* app_env_var_prefix);
154
168WS_DLL_PUBLIC char *get_datafile_path(const char *filename, const char* app_env_var_prefix);
169
179WS_DLL_PUBLIC const char *get_doc_dir(const char* app_env_var_prefix);
180
194WS_DLL_PUBLIC char *get_docfile_path(const char *filename, const char* app_env_var_prefix);
195
209WS_DLL_PUBLIC char *doc_file_url(const char *filename, const char* app_env_var_prefix);
210
221WS_DLL_PUBLIC const char *get_systemfile_dir(const char* app_env_var_prefix);
222
231WS_DLL_PUBLIC void set_profile_name(const char *profilename);
232
241WS_DLL_PUBLIC const char *get_profile_name(void);
242
251WS_DLL_PUBLIC bool is_default_profile(void);
252
262WS_DLL_PUBLIC bool has_global_profiles(const char* app_env_var_prefix);
263
273WS_DLL_PUBLIC char *get_profiles_dir(const char* app_env_var_prefix);
274
289WS_DLL_PUBLIC char *get_profile_dir(const char* app_env_var_prefix, const char *profilename, bool is_global);
290
305WS_DLL_PUBLIC int create_profiles_dir(const char* app_env_var_prefix, char **pf_dir_path_return);
306
316WS_DLL_PUBLIC char *get_global_profiles_dir(const char* app_env_var_prefix);
317
326WS_DLL_PUBLIC void profile_store_persconffiles(bool store);
327
337WS_DLL_PUBLIC void profile_register_persconffile(const char *filename);
338
350WS_DLL_PUBLIC bool profile_exists(const char* app_env_var_prefix, const char *profilename, bool global);
351
366WS_DLL_PUBLIC int create_persconffile_profile(const char* app_env_var_prefix, const char *profilename,
367 char **pf_dir_path_return);
368
379WS_DLL_PUBLIC const GHashTable *allowed_profile_filenames(void);
380
395WS_DLL_PUBLIC int delete_persconffile_profile(const char* app_env_var_prefix, const char *profilename,
396 char **pf_dir_path_return);
397
415WS_DLL_PUBLIC int rename_persconffile_profile(const char* app_env_var_prefix, const char *fromname, const char *toname,
416 char **pf_from_dir_path_return,
417 char **pf_to_dir_path_return);
418
437WS_DLL_PUBLIC int copy_persconffile_profile(const char* app_env_var_prefix, const char *toname, const char *fromname,
438 bool from_global,
439 char **pf_filename_return,
440 char **pf_to_dir_path_return,
441 char **pf_from_dir_path_return);
442
456WS_DLL_PUBLIC int create_persconffile_dir(const char* app_env_var_prefix, char **pf_dir_path_return);
457
472WS_DLL_PUBLIC char *get_persconffile_path(const char *filename, bool from_profile, const char* app_env_var_prefix);
473
482WS_DLL_PUBLIC void set_persconffile_dir(const char *p);
483
493WS_DLL_PUBLIC const char *get_persdatafile_dir(void);
494
503WS_DLL_PUBLIC void set_persdatafile_dir(const char *p);
504
514WS_DLL_PUBLIC WS_RETNONNULL const char *get_current_working_dir(void);
515
526WS_DLL_PUBLIC const char *file_open_error_message(int err, bool for_writing);
527
537WS_DLL_PUBLIC const char *file_write_error_message(int err);
538
548WS_DLL_PUBLIC const char *get_basename(const char *path);
549
560WS_DLL_PUBLIC char *find_last_pathname_separator(const char *path);
561
573WS_DLL_PUBLIC char *get_dirname(char *path);
574
589WS_DLL_PUBLIC int test_for_directory(const char *path);
590
605WS_DLL_PUBLIC int test_for_fifo(const char *path);
606
617WS_DLL_PUBLIC bool test_for_regular_file(const char *path);
618
628WS_DLL_PUBLIC bool file_exists(const char *fname);
629
641WS_DLL_PUBLIC bool config_file_exists_with_entries(const char *fname, char comment_char);
642
654WS_DLL_PUBLIC bool files_identical(const char *fname1, const char *fname2);
655
668WS_DLL_PUBLIC bool file_needs_reopen(int fd, const char* filename);
669
685WS_DLL_PUBLIC bool write_file_binary_mode(const char *filename,
686 const void *content, size_t content_len);
687
702WS_DLL_PUBLIC bool copy_file_binary_mode(const char *from_filename,
703 const char *to_filename);
704
705
718WS_DLL_PUBLIC char* data_file_url(const char *filename, const char* app_env_var_prefix);
719
727WS_DLL_PUBLIC void free_progdirs(void);
728
729#ifdef __cplusplus
730}
731#endif /* __cplusplus */
732
733#endif /* FILESYSTEM_H */
WS_DLL_PUBLIC char * doc_file_url(const char *filename, const char *app_env_var_prefix)
Constructs the URL path to a global documentation file.
Definition filesystem.c:2700
WS_DLL_PUBLIC char * get_profiles_dir(const char *app_env_var_prefix)
Gets the directory used to store configuration profile directories.
Definition filesystem.c:1661
WS_DLL_PUBLIC const char * get_basename(const char *path)
Returns the last component of a pathname.
Definition filesystem.c:109
WS_DLL_PUBLIC int test_for_fifo(const char *path)
Tests whether a given pathname refers to a FIFO (named pipe).
Definition filesystem.c:190
WS_DLL_PUBLIC const char * get_persdatafile_dir(void)
Gets the default directory in which personal data is stored.
Definition filesystem.c:2095
WS_DLL_PUBLIC char * get_dirname(char *path)
Returns the directory portion of a pathname.
Definition filesystem.c:136
WS_DLL_PUBLIC const char * get_profile_name(void)
Gets the current configuration profile name used for storing personal configuration files.
Definition filesystem.c:1443
WS_DLL_PUBLIC int copy_persconffile_profile(const char *app_env_var_prefix, const char *toname, const char *fromname, bool from_global, char **pf_filename_return, char **pf_to_dir_path_return, char **pf_from_dir_path_return)
Copies configuration files from one profile to another.
Definition filesystem.c:2035
WS_DLL_PUBLIC char * configuration_init(const char *arg0, const char *app_flavor_lower)
Initialize our configuration environment.
Definition filesystem.c:904
WS_DLL_PUBLIC int delete_persconffile_profile(const char *app_env_var_prefix, const char *profilename, char **pf_dir_path_return)
Deletes the directory for the given configuration profile.
Definition filesystem.c:1886
WS_DLL_PUBLIC void set_profile_name(const char *profilename)
Sets the configuration profile name for storing personal configuration files.
Definition filesystem.c:1429
WS_DLL_PUBLIC char * get_docfile_path(const char *filename, const char *app_env_var_prefix)
Constructs the full path to a global documentation file.
Definition filesystem.c:2206
WS_DLL_PUBLIC void set_persconffile_dir(const char *p)
Sets the path of the personal configuration file directory.
Definition filesystem.c:1654
WS_DLL_PUBLIC void set_persdatafile_dir(const char *p)
Sets the path of the directory in which personal data is stored.
Definition filesystem.c:2138
WS_DLL_PUBLIC const char * get_plugins_dir_with_version(const char *app_env_var_prefix)
Append VERSION_MAJOR.VERSION_MINOR to the plugin dir.
Definition filesystem.c:1252
WS_DLL_PUBLIC char * get_global_profiles_dir(const char *app_env_var_prefix)
Gets the directory used to store global configuration profile directories.
Definition filesystem.c:1707
WS_DLL_PUBLIC bool has_global_profiles(const char *app_env_var_prefix)
Checks whether global configuration profiles are available.
Definition filesystem.c:1459
WS_DLL_PUBLIC const char * get_progfile_dir(void)
Get the directory in which the main (Wireshark, TShark, Stratoshark, etc) program resides.
Definition filesystem.c:917
WS_DLL_PUBLIC bool copy_file_binary_mode(const char *from_filename, const char *to_filename)
Copies a file using binary mode.
Definition filesystem.c:2616
WS_DLL_PUBLIC const char * get_doc_dir(const char *app_env_var_prefix)
Gets the directory in which global documentation files are stored.
WS_DLL_PUBLIC bool config_file_exists_with_entries(const char *fname, char comment_char)
Checks if a configuration file exists and contains non-comment entries.
Definition filesystem.c:2374
WS_DLL_PUBLIC const char * get_plugins_dir(const char *app_env_var_prefix)
Get the directory in which plugins are stored.
Definition filesystem.c:1244
WS_DLL_PUBLIC bool files_identical(const char *fname1, const char *fname2)
Checks whether two filenames refer to the same file.
Definition filesystem.c:2412
WS_DLL_PUBLIC char * data_file_url(const char *filename, const char *app_env_var_prefix)
Constructs a filesystem URL from a given filename.
Definition filesystem.c:2679
WS_DLL_PUBLIC bool file_exists(const char *fname)
Checks whether a file exists.
Definition filesystem.c:2359
WS_DLL_PUBLIC WS_RETNONNULL const char * get_current_working_dir(void)
Gets the current working directory.
Definition filesystem.c:923
WS_DLL_PUBLIC const char * get_extcap_pers_dir(const char *app_env_var_prefix)
Gets the personal extcap directory.
Definition filesystem.c:1395
WS_DLL_PUBLIC char * get_executable_path(const char *filename)
Given the program name, construct the path name of a non-extcap Wireshark executable file.
Definition filesystem.c:533
WS_DLL_PUBLIC int create_persconffile_profile(const char *app_env_var_prefix, const char *profilename, char **pf_dir_path_return)
Creates a directory for the given configuration profile.
Definition filesystem.c:1932
WS_DLL_PUBLIC int rename_persconffile_profile(const char *app_env_var_prefix, const char *fromname, const char *toname, char **pf_from_dir_path_return, char **pf_to_dir_path_return)
Renames the directory for the given configuration profile.
Definition filesystem.c:1904
WS_DLL_PUBLIC void free_progdirs(void)
Frees internal program directory structures.
Definition filesystem.c:2721
WS_DLL_PUBLIC const char * get_extcap_dir(const char *app_env_var_prefix, const char *dir_extcap)
Gets the directory in which extcap hooks are stored.
Definition filesystem.c:1386
WS_DLL_PUBLIC int create_persconffile_dir(const char *app_env_var_prefix, char **pf_dir_path_return)
Creates the directory that holds personal configuration files, if necessary.
Definition filesystem.c:2029
WS_DLL_PUBLIC bool file_needs_reopen(int fd, const char *filename)
Checks whether a file has been recreated since it was opened.
Definition filesystem.c:2485
WS_DLL_PUBLIC char * get_datafile_path(const char *filename, const char *app_env_var_prefix)
Constructs the full path to a global configuration file.
Definition filesystem.c:2184
WS_DLL_PUBLIC const char * get_datafile_dir(const char *app_env_var_prefix)
Gets the directory in which global configuration files are stored.
Definition filesystem.c:985
WS_DLL_PUBLIC int test_for_directory(const char *path)
Tests whether a given pathname refers to a directory.
Definition filesystem.c:176
WS_DLL_PUBLIC bool running_in_build_directory(void)
Indicates whether Wireshark is running from a build directory.
Definition filesystem.c:1407
WS_DLL_PUBLIC int create_profiles_dir(const char *app_env_var_prefix, char **pf_dir_path_return)
Creates the directory used to store configuration profile directories.
Definition filesystem.c:1668
WS_DLL_PUBLIC const char * get_systemfile_dir(const char *app_env_var_prefix)
Gets the directory in which system files are stored.
WS_DLL_PUBLIC char * get_profile_dir(const char *app_env_var_prefix, const char *profilename, bool is_global)
Gets the directory used to store configuration files for a given profile.
Definition filesystem.c:1732
WS_DLL_PUBLIC void profile_register_persconffile(const char *filename)
Registers a filename to the personal configuration files storage.
Definition filesystem.c:1496
WS_DLL_PUBLIC const char * file_open_error_message(int err, bool for_writing)
Returns a human-readable error message for file open or create failures.
Definition filesystem.c:2225
WS_DLL_PUBLIC const char * file_write_error_message(int err)
Returns a human-readable error message for write operation failures.
Definition filesystem.c:2330
WS_DLL_PUBLIC const char * get_plugins_pers_dir_with_version(const char *app_env_var_prefix)
Appends VERSION_MAJOR.VERSION_MINOR to the personal plugin directory path.
Definition filesystem.c:1271
WS_DLL_PUBLIC bool profile_exists(const char *app_env_var_prefix, const char *profilename, bool global)
Checks whether a given configuration profile exists.
Definition filesystem.c:1758
WS_DLL_PUBLIC char * get_persconffile_path(const char *filename, bool from_profile, const char *app_env_var_prefix)
Constructs the full path name of a personal configuration file.
Definition filesystem.c:2158
WS_DLL_PUBLIC bool write_file_binary_mode(const char *filename, const void *content, size_t content_len)
Writes raw content to a file in binary mode.
Definition filesystem.c:2550
WS_DLL_PUBLIC const GHashTable * allowed_profile_filenames(void)
Returns the list of known profile configuration filenames.
Definition filesystem.c:2023
WS_DLL_PUBLIC void profile_store_persconffiles(bool store)
Enables or disables tracking of personal configuration file names for profile duplication.
Definition filesystem.c:1487
WS_DLL_PUBLIC bool is_default_profile(void)
Checks whether the current configuration profile is the default profile.
Definition filesystem.c:1453
WS_DLL_PUBLIC char * find_last_pathname_separator(const char *path)
Returns a pointer to the last pathname separator in a given path.
Definition filesystem.c:76
WS_DLL_PUBLIC bool test_for_regular_file(const char *path)
Tests whether a given pathname refers to a regular file.
Definition filesystem.c:204
WS_DLL_PUBLIC const char * get_plugins_pers_dir(const char *app_env_var_prefix)
Gets the personal plugin directory.
Definition filesystem.c:1263