> For the complete documentation index, see [llms.txt](https://sandbox-docs.verifone.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/namespaces/namespacesdi/namespacesdi_1_1filesystem.md).

# filesystem

[Data Structures](#nested-classes) | [Enumerations](#enum-members) | [Functions](#func-members) | [Variables](#var-members)

|                 |                                                          |
| --------------- | -------------------------------------------------------- |
| Data Structures |                                                          |
| struct          | [UpdateFiles](#structsdi_1_1filesystem_1_1_update_files) |

|              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enumerations |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| enum         | <p><a href="#aecaf6a9545fa815deb4b8e64e144ce43">Location</a> {<br>  <a href="#aecaf6a9545fa815deb4b8e64e144ce43a3b40dfe58ff7a5a338c90da1545ec573">LOC\_None</a>, <a href="#aecaf6a9545fa815deb4b8e64e144ce43a878e84fff242aa27fa3ec07e9df71ea0">LOC\_SdiFlashDir</a>, <a href="#aecaf6a9545fa815deb4b8e64e144ce43aec2d78a615b70e9f406ed59e7e089137">LOC\_SdiConfigDir</a>, <a href="#aecaf6a9545fa815deb4b8e64e144ce43ab7bebc1fd312b79d4400b0bd715d837c">LOC\_SdiExtConfigDir</a>,<br>  <a href="#aecaf6a9545fa815deb4b8e64e144ce43a2adeec59d3dfd549c01ce9105dce5f5b">LOC\_EmvFlashDir</a>, <a href="#aecaf6a9545fa815deb4b8e64e144ce43aa652c98e536a9dd60108b492c7d56501">LOC\_EmvConfigDir</a>, <a href="#aecaf6a9545fa815deb4b8e64e144ce43a28744a191aee5516275e3a88c20a0851">LOC\_LogConfigDir</a>, <a href="#aecaf6a9545fa815deb4b8e64e144ce43a836a3a9c2556f7f29455d5fc7a9cf19c">LOC\_NfcFlashDir</a>,<br>  <a href="#aecaf6a9545fa815deb4b8e64e144ce43acfc7b9731795d36feedccae005c07052">LOC\_SdiExtFontsDir</a><br>}</p>                                                                                                                                                                                                                                                                                                    |
| enum         | <p><a href="#a8bb1ef53467e4f61410d12822d922498">Action</a> {<br>  <a href="#a8bb1ef53467e4f61410d12822d922498a56fb111b33a737bdddf89dd9568687df">ACT\_None</a> = 0, <a href="#a8bb1ef53467e4f61410d12822d922498a3938f7524a0b71efd9adfd59a5f35f83">ACT\_SecInit</a> = (1 << 0), <a href="#a8bb1ef53467e4f61410d12822d922498aae9ce02546bfc5b212048612e81b0825">ACT\_DisableEpp</a> = (1 << 1), <a href="#a8bb1ef53467e4f61410d12822d922498a531ff0d0f64adc3d9a04d15f268488da">ACT\_EmvExit</a> = (1 << 2),<br>  <a href="#a8bb1ef53467e4f61410d12822d922498a1a0540a4bf370403942cf6c61cbf5a3c">ACT\_EmvExitComplete</a> = (1 << 3), <a href="#a8bb1ef53467e4f61410d12822d922498af5c01ad9c75206913bc3a8494842e468">ACT\_EmvFlashPerm</a> = (1 << 4), <a href="#a8bb1ef53467e4f61410d12822d922498ae62045a4320284f9bc06396b757bf777">ACT\_EmvInitInfo</a> = (1 << 5), <a href="#a8bb1ef53467e4f61410d12822d922498a3e449095c7a30b5021d4675cde6d19c3">ACT\_LogInit</a> = (1 << 6),<br>  <a href="#a8bb1ef53467e4f61410d12822d922498aeb9762197fdaecdeb2b76f59609636a5">ACT\_CardRanges</a> = (1 << 7), <a href="#a8bb1ef53467e4f61410d12822d922498ab4b30277a00cda99b05dac98fe652c2f">ACT\_WhitelistFile</a> = (1 << 8), <a href="#a8bb1ef53467e4f61410d12822d922498a3b94499f650fd93b67a6d89f1420bcae">ACT\_AclInit</a> = (1 << 9)<br>}</p> |
| enum         | [ActionSource](#a69f0011e8e844cb97a3507c1da3aa656) { [ASRC\_Default](#a69f0011e8e844cb97a3507c1da3aa656a741d7fd60e2d656f4d4b71f9a29e79df) = 0, [ASRC\_Removal](#a69f0011e8e844cb97a3507c1da3aa656a49f1485000653c3415ca12d3b95637c5) = (1 << 0), [ASRC\_PostAction](#a69f0011e8e844cb97a3507c1da3aa656a3c65ad6d8cd1e0a6bcd6852569b3b0d9) = (1 << 1) }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| enum         | <p><a href="#aa9aa79c14f6b639710c956e0e038b44a">DirModes</a> {<br>  <a href="#aa9aa79c14f6b639710c956e0e038b44aa8d0920ced57abc9fe493ec1ef5e6be73">DM\_Default</a> = 0, <a href="#aa9aa79c14f6b639710c956e0e038b44aa3cac4d0c25a1f2b530db02594a6c6328">DM\_Recursive</a> = 1, <a href="#aa9aa79c14f6b639710c956e0e038b44aa9ec7e5e8da3dc2cb198deb84f16063a3">DM\_Relative</a> = 2, <a href="#aa9aa79c14f6b639710c956e0e038b44aaf465ca4f75cce028de114133c56a8396">DM\_NoAbort</a> = 4,<br>  <a href="#aa9aa79c14f6b639710c956e0e038b44aacfe82c71202e06dc4fbe92d9d63a9f00">DM\_MatchFileOnly</a> = 8, <a href="#aa9aa79c14f6b639710c956e0e038b44aa130af116abe118ac14257c8858a3f5b3">DM\_MatchInverted</a> = 16<br>}</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| enum         | [FilesModes](#a0b27accd35d4c377ef3a7c04b82a8b1f) { [FM\_Default](#a0b27accd35d4c377ef3a7c04b82a8b1fa01ae168a66b5e79c94c5eccc153602b1) = 0, [FM\_NoAbort](#a0b27accd35d4c377ef3a7c04b82a8b1fa47ea781826f29e64b46f2feb5780be07) = 1, [FM\_Quiet](#a0b27accd35d4c377ef3a7c04b82a8b1faf990ad75b23de549d4a319237a47974f) = 2, [FM\_KeepTopDir](#a0b27accd35d4c377ef3a7c04b82a8b1fa1a3a418ff306a51b0124aca8c1ca1bac) = 4 }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |

|                |                                                                                                                                                                                                                                         |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Functions      |                                                                                                                                                                                                                                         |
| void           | [factory\_reset](#a12545d574e9182af24a177d1cf453c0c) ()                                                                                                                                                                                 |
| void           | [init](#a43918d493a7f56eef174f3c9a82a8e20) (enum config::SdiSysConfig::SDIMode sdi\_mode)                                                                                                                                               |
| bool           | [read\_file](#a141d15606acd013831d2e4ead7765ab5) (const char \*file, string \&data)                                                                                                                                                     |
| bool           | [write\_file](#a3a27a49de579060fada2de1f1fcb72c5) (const char \*file, const string \&data)                                                                                                                                              |
| bool           | [copy\_file](#a738972c314285885ecc6cbf7a864339a) (const string \&src, const string \&dest)                                                                                                                                              |
| bool           | [move\_file](#a5dd1f08cec548612d55ff24e08ae4dcd) (const string \&src, const string \&dst)                                                                                                                                               |
| int            | [get\_dir\_files](#a5800b7dc05dcfb436ec8f8c100757ac7) (const char \*dir, vector< string > \*files, const char \*regex, unsigned modes)                                                                                                  |
| int            | [copy\_files](#a8f5d2647f4272f5b555144ad2c9f5239) (const vector< string > \&files, const char \*dst\_dir, unsigned modes)                                                                                                               |
| int            | [remove\_dir](#a8241068dfa57d30c7be7a289815533bf) (const string \&path, unsigned modes)                                                                                                                                                 |
| int            | [remove\_files](#a95279759f98284266e220092cbb51508) (const vector< string > \&files, unsigned modes)                                                                                                                                    |
| const char \*  | [binary\_dir](#a52dd354a0640fd070653611d6de4722b) ()                                                                                                                                                                                    |
| string         | [home\_flash\_file](#aabc728c4e4c0574111826ca732390cca) (const string \&file)                                                                                                                                                           |
| string         | [home\_config\_file](#adebb7050fa15bdc4361a3d24f2c6e2f3) (const string \&file)                                                                                                                                                          |
| string         | [lookup\_config\_file](#aae28890912feff7f83d3af43e35b986c) (const string \&file)                                                                                                                                                        |
| const char \*  | [plugin\_config\_dir](#a383b7331d5268ea154c61f4ff4eb6ab8) ()                                                                                                                                                                            |
| int            | [extract\_tar](#a71438e4a73e8ac1cecae82089cd9dded) (const string \&tarfile, const string \&destdir, const char \*regex)                                                                                                                 |
| unsigned short | [install\_emv\_config\_package](#a7412f8e8dc1ea4a649358a45031df492) (const string \&emv\_config\_pkg)                                                                                                                                   |
| const char \*  | [home\_flash\_dir](#a0de1824701ee8494b54c3c97cb17039b) ()                                                                                                                                                                               |
| const char \*  | [home\_config\_dir](#a1eee0f47abbf3108854b4178e194ba45) ()                                                                                                                                                                              |
| const char \*  | [ext\_config\_dir](#a1518fc71a30bfab59f82fc1a2726c627) ()                                                                                                                                                                               |
| const char \*  | [emv\_flash\_dir](#a817ffa0e3dd4d66ee5a1717aac4c94b8) ()                                                                                                                                                                                |
| const char \*  | [emv\_config\_dir](#a65ac0c4801674fbc1832569c7f34457d) ()                                                                                                                                                                               |
| const char \*  | [log\_config\_dir](#a1ba2e0d2621785a746e8a2bc2b85bfab) ()                                                                                                                                                                               |
| const char \*  | [nfc\_flash\_dir](#a3eb6af6e0de2e982c40979a8282da21b) ()                                                                                                                                                                                |
| const char \*  | [home\_lib\_dir](#a98b1808447b0f9e7848b35156a4c7cc9) ()                                                                                                                                                                                 |
| const char \*  | [ext\_plugin\_dir](#ae7f61379f5979fbb09444be76ab12a1f) ()                                                                                                                                                                               |
| const char \*  | [ext\_font\_dir](#a01f85298159181054db31598024a039e) ()                                                                                                                                                                                 |
| const char \*  | [tmp\_dir](#a9bc32456ce574dce7e0dbee9f49ed5cd) ()                                                                                                                                                                                       |
| const char \*  | [upload\_install\_dir](#a34a571792ddd1cbbe291af193597d9a0) (bool flash)                                                                                                                                                                 |
| const char \*  | [sys\_remove\_sponsor\_dir](#a6c67d203b4323cce1f3c274d3f2827ee) ()                                                                                                                                                                      |
| const char \*  | [ccp\_resource\_dir](#ac4b7a1244864c6c42d667f71e517c129) ()                                                                                                                                                                             |
| const char \*  | [ccp\_database\_dir](#a8705c6880d517d88098ddd7aa1e3716d) ()                                                                                                                                                                             |
| const char \*  | [sdi\_update\_dir](#a62f821b6937b4f380d3e22cde31d2920) ()                                                                                                                                                                               |
| const char \*  | [sdi\_persist\_dir](#aeddca685a1e934168171cfef8ef8697e) (bool system)                                                                                                                                                                   |
| const char \*  | [sdi\_certstore\_dir](#abfa13da98e3a50c8c79f55671a6c71be) ()                                                                                                                                                                            |
| unsigned short | [install\_user\_configuration](#ad41174b98a363bf48bbcfc62984939ef) (bool recover)                                                                                                                                                       |
| unsigned short | [remove\_user\_configuration](#abfc178565b6c9e326831f7ef51646744) ()                                                                                                                                                                    |
| unsigned short | [install\_sdi\_plugins](#af65203b969499e2d36e34c08172a9f30) (bool recover)                                                                                                                                                              |
| unsigned short | [remove\_sdi\_plugins](#ac42ad54eda4b15aa9d9f2d7bda4a55a5) ()                                                                                                                                                                           |
| bool           | [read\_file](#ad9ecf729e46fab7ad576ed4bc9b4b2cf) (const char \*file, std::string \&data)                                                                                                                                                |
| bool           | [write\_file](#a0c3b0966ff7d9a48ffef25f5c1715e82) (const char \*file, const std::string \&data)                                                                                                                                         |
| bool           | [copy\_file](#afa6d3c16d20a51cd378284f6829cebf0) (const std::string \&src, const std::string \&dest)                                                                                                                                    |
| bool           | [move\_file](#acc0eb80e0e44c07c5f0edfa0763150a5) (const std::string \&src, const std::string \&dest)                                                                                                                                    |
| int            | [get\_dir\_files](#a5ae3528937fc6432706c8125728154c8) (const char \*dir, std::vector< std::string > \*files=0, const char \*regex=0, unsigned modes=[DM\_Default](#aa9aa79c14f6b639710c956e0e038b44aa8d0920ced57abc9fe493ec1ef5e6be73)) |
| int            | [copy\_files](#a97c401199b467196a4e427c5c51ac5d3) (const std::vector< std::string > \&files, const char \*dst\_dir, unsigned modes=[FM\_Default](#a0b27accd35d4c377ef3a7c04b82a8b1fa01ae168a66b5e79c94c5eccc153602b1))                  |
| int            | [remove\_files](#ae04fc0d5bbc079cc49174bbe72ec2d7c) (const std::vector< std::string > \&files, unsigned modes=[FM\_Default](#a0b27accd35d4c377ef3a7c04b82a8b1fa01ae168a66b5e79c94c5eccc153602b1))                                       |
| int            | [remove\_dir](#add3a308833cddc7775215c8fc3d1d608) (const std::string \&path, unsigned modes=[FM\_Default](#a0b27accd35d4c377ef3a7c04b82a8b1fa01ae168a66b5e79c94c5eccc153602b1))                                                         |
| int            | [extract\_tar](#a3f65ebfc86c128bc4d198e376e187ff7) (const std::string \&tarfile, const std::string \&destdir, const char \*regex=0)                                                                                                     |
| std::string    | [home\_flash\_file](#a5748ac7656cef8d6b10941d76eac115d) (const std::string \&file)                                                                                                                                                      |
| std::string    | [home\_config\_file](#ab8862ea906c088c55072c8ea390c0adc) (const std::string \&file)                                                                                                                                                     |
| std::string    | [lookup\_config\_file](#a3f6f1faaea3bfa5fb011c57ec15c7749) (const std::string \&file)                                                                                                                                                   |
| unsigned short | [install\_emv\_config\_package](#a292b4583cbbd3327c059f32edc6e6168) (const std::string \&emv\_config\_pkg)                                                                                                                              |

|                                                                       |                                                                                                                                                                                                               |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Variables                                                             |                                                                                                                                                                                                               |
| const struct [UpdateFiles](#structsdi_1_1filesystem_1_1_update_files) | [allowed\_usr\_files](#af64ea9fc2f13d8f3be606630ef0436cd) \[]                                                                                                                                                 |
| const unsigned                                                        | [allowed\_usr\_files\_size](#a8ab079877b3d40867b387ea29bf1db93) = (sizeof([allowed\_usr\_files](#af64ea9fc2f13d8f3be606630ef0436cd)) / sizeof([allowed\_usr\_files](#af64ea9fc2f13d8f3be606630ef0436cd)\[0])) |

***

### DataStructure Documentation <a href="#data-structure-documentation" id="data-structure-documentation"></a>

### sdi::filesystem::UpdateFiles <a href="#structsdi_1_1filesystem_1_1_update_files" id="structsdi_1_1filesystem_1_1_update_files"></a>

struct sdi::filesystem::UpdateFiles

update file definition to check for allowed files to update and remove

|                                                     |               |                                                                                |
| --------------------------------------------------- | ------------- | ------------------------------------------------------------------------------ |
| Data Fields                                         |               |                                                                                |
| enum [Location](#aecaf6a9545fa815deb4b8e64e144ce43) | dest          | destination on terminal, see enum Dest                                         |
| const char \*                                       | dest\_prefix  | file prefix (path) used in application folder (if any)                         |
| const char \*                                       | file          | name of the update file (without path)                                         |
| unsigned long                                       | post\_actions | post-actions (bitmask) to execute for this file after update (see enum Action) |
| unsigned long                                       | pre\_actions  | pre-actions (bitmask) to execute for this file before update (see enum Action) |
| const char \*                                       | prefix        | file prefix (path) in the user configuration package                           |
| bool                                                | regex         | file is already a regular expression                                           |

### EnumerationType Documentation <a href="#enumeration-type-documentation" id="enumeration-type-documentation"></a>

### Action <a href="#a8bb1ef53467e4f61410d12822d922498" id="a8bb1ef53467e4f61410d12822d922498"></a>

enum \[Action]\(#a8bb1ef53467e4f61410d12822d922498)

actions supported by run\_actions() below (bitmask used to combine actions). Order of execution is sprecified by run\_actions() and recently corresponds to enum order.

|                      |                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enumerator           |                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ACT\_None            | no action                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ACT\_SecInit         | call [secInit()](/adk-5.0-programmers-guide/readme/modules/group__com__verifone__seccmd/namespacecom__verifone__seccmd.md#ab649bee85abb5cb4085c3958f279483d) for this file (Android only)                                                                                                                                                                                                                                        |
| ACT\_DisableEpp      | disable attached EPP (if enabled as Countertop)                                                                                                                                                                                                                                                                                                                                                                                  |
| ACT\_EmvExit         | call [EMV\_CT\_Exit\_Framework()](/adk-5.0-programmers-guide/readme/modules/group___a_d_k___i_n_i_t_i_a_l_i_z_a_t_i_o_n___c_t/group___f_u_n_c___i_n_i_t___c_t.md#gaad2d6cdd1249528199d5dc969e48b43c) and [EMV\_CTLS\_Exit\_Framework()](/adk-5.0-programmers-guide/readme/modules/group___a_d_k___i_n_i_t_i_a_l_i_z_a_t_i_o_n___c_t_l_s/group___f_u_n_c___i_n_i_t___c_t_l_s.md#gafe86c6980355b69b6a650af0bffcb7ed) for this file |
| ACT\_EmvExitComplete | call EMV\_CT\_Exit\_Framework\_extended(EXIT\_CT\_COMPLETE) and EMV\_CTLS\_Exit\_Framework\_extended(EXIT\_CTLS\_COMPLETE) for this file                                                                                                                                                                                                                                                                                         |
| ACT\_EmvFlashPerm    | call set\_emv\_flash\_permissions() on EMV flash config folder (VOS/VOS2/VOS3 only) Note: ACT\_EmvFlashPerm must be below ACT\_EmvInitInfo so that it is executed before ACT\_EmvInitInfo as both are used together in [install\_emv\_config\_package()](#a7412f8e8dc1ea4a649358a45031df492)                                                                                                                                     |
| ACT\_EmvInitInfo     | call initEmvInfo() to rebuild EMV Info cache                                                                                                                                                                                                                                                                                                                                                                                     |
| ACT\_LogInit         | call LogAPI\_ReconfigNotification() for this file                                                                                                                                                                                                                                                                                                                                                                                |
| ACT\_CardRanges      | reload cache for card ranges configuration                                                                                                                                                                                                                                                                                                                                                                                       |
| ACT\_WhitelistFile   | reload cache for whitelist configuration                                                                                                                                                                                                                                                                                                                                                                                         |
| ACT\_AclInit         | reload ACL (access control list) file                                                                                                                                                                                                                                                                                                                                                                                            |

### ActionSource <a href="#a69f0011e8e844cb97a3507c1da3aa656" id="a69f0011e8e844cb97a3507c1da3aa656"></a>

enum \[ActionSource]\(#a69f0011e8e844cb97a3507c1da3aa656)

action source specifying for what run\_actions() was invoked

|                  |                                                                                 |
| ---------------- | ------------------------------------------------------------------------------- |
| Enumerator       |                                                                                 |
| ASRC\_Default    | default: installation (see ASRC\_Removal) and pre-action (see ASRC\_PostAction) |
| ASRC\_Removal    | removal (not installation)                                                      |
| ASRC\_PostAction | post-action (not pre-action)                                                    |

### DirModes <a href="#aa9aa79c14f6b639710c956e0e038b44a" id="aa9aa79c14f6b639710c956e0e038b44a"></a>

enum \[DirModes]\(#aa9aa79c14f6b639710c956e0e038b44a)

|                   |                                                                                                                |
| ----------------- | -------------------------------------------------------------------------------------------------------------- |
| Enumerator        |                                                                                                                |
| DM\_Default       | default mode (all below disalbed)                                                                              |
| DM\_Recursive     | set this mode do consider subdirectories (recursive walk), default: flat walk in `dir` only                    |
| DM\_Relative      | let vector `files` return relative path to `dir`, default: absolute paths returned                             |
| DM\_NoAbort       | function proceeds on error (e.g. in case of subdirectory cannot be accessed/opended)                           |
| DM\_MatchFileOnly | if provided, apply `regex` on filename only (w/o path prefix)                                                  |
| DM\_MatchInverted | use inverted match result, to simplify regex (e.g. "^kpi\\/" will return all entries not beginning with "kpi/" |

### FilesModes <a href="#a0b27accd35d4c377ef3a7c04b82a8b1f" id="a0b27accd35d4c377ef3a7c04b82a8b1f"></a>

enum \[FilesModes]\(#a0b27accd35d4c377ef3a7c04b82a8b1f)

modes for functions [copy\_files()](#a8f5d2647f4272f5b555144ad2c9f5239), [remove\_files()](#a95279759f98284266e220092cbb51508), [remove\_dir()](#a8241068dfa57d30c7be7a289815533bf)

|                |                                                                                                                                      |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Enumerator     |                                                                                                                                      |
| FM\_Default    | let first file error abort the function with -1.                                                                                     |
| FM\_NoAbort    | function proceeds, in case of single files cannot be copied or removed. Function returns with number of successfully pocessed files. |
| FM\_Quiet      | don't issue information to log (errors only), e.g. for non-existing files                                                            |
| FM\_KeepTopDir | only supported for [remove\_dir()](#a8241068dfa57d30c7be7a289815533bf): keep top level directory, after the content was removed      |

### Location <a href="#aecaf6a9545fa815deb4b8e64e144ce43" id="aecaf6a9545fa815deb4b8e64e144ce43"></a>

enum \[Location]\(#aecaf6a9545fa815deb4b8e64e144ce43)

file location directory for SDI configuration files

|                      |                                                                                  |
| -------------------- | -------------------------------------------------------------------------------- |
| Enumerator           |                                                                                  |
| LOC\_None            | No directory                                                                     |
| LOC\_SdiFlashDir     | SDI flash configuration directory (read/write)                                   |
| LOC\_SdiConfigDir    | SDI internal configuration directory (read-only)                                 |
| LOC\_SdiExtConfigDir | SDI directory for external user configuration (read-only)                        |
| LOC\_EmvFlashDir     | EMV flash configuration directory (read/write)                                   |
| LOC\_EmvConfigDir    | EMV configuration directory (read-only)                                          |
| LOC\_LogConfigDir    | ADK Logging configuration directory (read-only)                                  |
| LOC\_NfcFlashDir     | ADK NFC configuration directory (read/write)                                     |
| LOC\_SdiExtFontsDir  | SDI directory for external fonts (installed with user config package (read-only) |

### FunctionDocumentation <a href="#function-documentation" id="function-documentation"></a>

### binary\_dir() <a href="#a52dd354a0640fd070653611d6de4722b" id="a52dd354a0640fd070653611d6de4722b"></a>

const char \\\* binary\_dir

return the absolute path to the SDI server binary (without filename)

#### Returns

absolute path to SDI server binary

{% hint style="info" %}
On Titus, this function returns an empty string.
{% endhint %}

### ccp\_database\_dir() <a href="#a8705c6880d517d88098ddd7aa1e3716d" id="a8705c6880d517d88098ddd7aa1e3716d"></a>

const char \\\* ccp\_database\_dir

return absolute path to database folder of CCP (ADK COM CONTROL PANEL) (VOS/VOS2/VOS3: $HOME/flash/com) (Android: NULL, no CCP support)

{% hint style="info" %}
This function returns NULL, if the platform has no CCP support.
{% endhint %}

#### Returns

absolute path to CCP resource directory or NULL in case of error/no CCP support

### ccp\_resource\_dir() <a href="#ac4b7a1244864c6c42d667f71e517c129" id="ac4b7a1244864c6c42d667f71e517c129"></a>

const char \\\* ccp\_resource\_dir

return absolute path to resource folder of CCP (ADK COM CONTROL PANEL) (VOS/VOS2/VOS3: \<ext\_cfg\_dir>/ccp/www or $HOME/www/ccp or NULL, if no resources are found. \<ext\_cfg\_dir> as provided by [ext\_config\_dir()](#a1518fc71a30bfab59f82fc1a2726c627)) (Android: NULL, no CCP support)

{% hint style="info" %}
This function returns NULL, if the platform has no CCP support.
{% endhint %}

#### Returns

absolute path to CCP resource directory or NULL in case of error/no CCP support

### copy\_file()\[1/2] <a href="#afa6d3c16d20a51cd378284f6829cebf0" id="afa6d3c16d20a51cd378284f6829cebf0"></a>

bool sdi::filesystem::copy\_file

helper function to copy a file from source `src` to destination `dest`.

**Parameters**

\[in] **src** source file location \[in] **dest** destination file location

#### Returns

true for success, else false for error

### copy\_file()\[2/2] <a href="#a738972c314285885ecc6cbf7a864339a" id="a738972c314285885ecc6cbf7a864339a"></a>

bool sdi::filesystem::copy\_file

### copy\_files()\[1/2] <a href="#a97c401199b467196a4e427c5c51ac5d3" id="a97c401199b467196a4e427c5c51ac5d3"></a>

int sdi::filesystem::copy\_files

helper function to copy multiple files to destination directory `dst_dir`. Source files to be copied are specified by vector `files`.

**Parameters**

\[in] **files** vector of files to be copied to destination directory \[in] **dst\_dir** path to destination directory, where the files are copied to \[in] **modes** function operation modes, see enum FilesModes

#### Returns

number of files, which were copied. -1 is returned in case of error due to missing directory or file access.

### copy\_files()\[2/2] <a href="#a8f5d2647f4272f5b555144ad2c9f5239" id="a8f5d2647f4272f5b555144ad2c9f5239"></a>

int sdi::filesystem::copy\_files

### emv\_config\_dir() <a href="#a65ac0c4801674fbc1832569c7f34457d" id="a65ac0c4801674fbc1832569c7f34457d"></a>

const char \\\* emv\_config\_dir

return the absolute path to folder for read-only EMV files. (VOS/VOS2: /etc/config/adkemv) (Android: $HOME) (VOS3: \<ext\_cfg\_dir>/emv; \<ext\_cfg\_dir> as provided by [ext\_config\_dir()](#a1518fc71a30bfab59f82fc1a2726c627)) (Titus: $HOME, with /sdi as $HOME, even emv-desired.xml is not supported on this platform)

{% hint style="info" %}
Required for SW update on Android. On VOS and Titus, this function is unused.
{% endhint %}

#### Returns

absolute path to HOME for read-only EMV files.

### emv\_flash\_dir() <a href="#a817ffa0e3dd4d66ee5a1717aac4c94b8" id="a817ffa0e3dd4d66ee5a1717aac4c94b8"></a>

const char \\\* emv\_flash\_dir

return the absolute path to flash folder for writeable EMV files. If the directory does not exist, it is created and group is adjusted for EMV usage. (VOS/VOS2: /mnt/flash/etc/config/adkemv) (VOS3: /mnt/appdata/versioned/globalshare/sdi/emv) (Android: $HOME/flash/adkemv) (Titus: $HOME/flash/adkemv, with /sdi as $HOME)

{% hint style="info" %}
Also required for SW update on Android and to access "EMV\_Terminal.xml" to get terminal language.
{% endhint %}

#### Returns

absolute path to shared flash folder for writeable EMV files

### ext\_config\_dir() <a href="#a1518fc71a30bfab59f82fc1a2726c627" id="a1518fc71a30bfab59f82fc1a2726c627"></a>

const char \\\* ext\_config\_dir

return the abloslute path of external SDI configuration folder directory. (VOS/VOS2: /etc/config/sdi) (VOS3: /home/usr\<X>/sdi) (Android: $HOME/sdi\_ext) (Titus: $HOME/ext, with /sdi as $HOME) This folder holds the external configuration files, which were installed by user configuration package to overload SDI default configuration. The external SDI configuration folder contains files for read access only.

#### Returns

absolute path to external SDI configuration folder (with read-only files)

{% hint style="info" %}
On VOS3 SDI checks at startup for the existence of the folder /home/usr\<X>/sdi starting from usr1 up to usr16. If the folder is found under a specific user, this user directory is applied for external SDI configuration. This means, the first user providing the folder wins, other users with higher user numbers will be ignored.
{% endhint %}

### ext\_font\_dir() <a href="#a01f85298159181054db31598024a039e" id="a01f85298159181054db31598024a039e"></a>

const char \\\* ext\_font\_dir

return the absolute path of the folder for external fonts. (Android: $HOME/fonts/sdi\_ext) (VOS/VOS2/VOS3: /usr/share/fonts) (Titus: \<ext\_cfg\_dir>/fonts; \<ext\_cfg\_dir> as provided by [ext\_config\_dir()](#a1518fc71a30bfab59f82fc1a2726c627), unused so far)

{% hint style="info" %}
This function is un-used on VOS, since fonts are installed with SI font packages to the system folder, we ADK components have access to use them. On Android, ADKPRT runs in context of SDI, therefore, fonts are installed with an user config package to application domain folder.
{% endhint %}

#### Returns

absolute path to external fonts directory or an empty string

### ext\_plugin\_dir() <a href="#ae7f61379f5979fbb09444be76ab12a1f" id="ae7f61379f5979fbb09444be76ab12a1f"></a>

const char \\\* ext\_plugin\_dir

return the absolute path of the folder for external plugins (Android: $HOME/plugins) (VOS/VOS2/VOS3/Titus: empty string)

{% hint style="info" %}
This folder is used on Android platform only, which must use a separate folder for plugins. External plugins come along with SDI plugin packages and on Android SDI server is not able to write to lib folder ([home\_lib\_dir()](#a98b1808447b0f9e7848b35156a4c7cc9)) due to missing write permissions. On platforms without external plugins folder (e.g. VOS), this function returns an empty string.
{% endhint %}

#### Returns

absolute path to external plugin directory or an empty string

### extract\_tar()\[1/2] <a href="#a3f65ebfc86c128bc4d198e376e187ff7" id="a3f65ebfc86c128bc4d198e376e187ff7"></a>

int sdi::filesystem::extract\_tar

helper function to extract all regular files in uncompressed tar file `tarfile` into directory `destdir`. Caller has the option to pass a regular expression `regex` to match specific files to be considered for extraction. Files, which do not match, are skipped/ignored. The regular expression is applied on the filename of the tar file entry, which looks as follows: Examples: file.json (file on root level) dir/file.json (file in subdirectory) If no regular expression is passed (NULL), all regular files of tar file are extracted.

**Parameters**

\[in] **tarfile** tar file, which shall be extracted \[in] **destdir** destination directory in which all files are extracted. If the directory does not exist yet, it will be created. \[in] **regex** regular expression to match specific files be considered or NULL to extract all regular files from the tar file.

#### Returns

number of files, which were extracted. -1 is returned in case of error (e.g. tar file is not found, not valid or is empty).

{% hint style="info" %}
The function does not consider empty directories, in addition, other files types (e.g. symbolic links) are ignored.
{% endhint %}

### extract\_tar()\[2/2] <a href="#a71438e4a73e8ac1cecae82089cd9dded" id="a71438e4a73e8ac1cecae82089cd9dded"></a>

int sdi::filesystem::extract\_tar

### factory\_reset() <a href="#a12545d574e9182af24a177d1cf453c0c" id="a12545d574e9182af24a177d1cf453c0c"></a>

void factory\_reset

perform a factory reset of SDI server. The function is invoked for external reset by command "Factory Reset (20-22)" and for internal reset by [init()](#a43918d493a7f56eef174f3c9a82a8e20), if the SDI mode has changed since last startup. The function does the following:

* It removes all writable files, which are modified by SDI server during runtime. In addition, all user config files are removed, which must be considered by the reset. On Titus, even system configuration files are removed.
* It creates writeable files (not belonging to user configuration packages) to restore other default settings, e.g. STATUS.CFG.
* On VOS platforms it synchronizes contents of installed user config packages to restore default configurations files coming along with these packages (see step 9 of [init()](#a43918d493a7f56eef174f3c9a82a8e20)). On Android user configuration files and SDI plugins are recovered from persitent partition. For this, functions install\_configuration() and [install\_sdi\_plugins()](#af65203b969499e2d36e34c08172a9f30) with flag `recover=true` are invoked. On Titus user and system configuration files are recovered from persist folder. For this, functions install\_configuration() with flag `recover=true` is invoked.

### get\_dir\_files()\[1/2] <a href="#a5ae3528937fc6432706c8125728154c8" id="a5ae3528937fc6432706c8125728154c8"></a>

int sdi::filesystem::get\_dir\_files

helper function to count and/or obtain all files in directory `dir`. Caller has the option to pass a regular expression `regex` to match specific files to be considered for the result. The regular expression is applied on the full file path including the path prefix. If no regular expression is passed (NULL), all regular files in the directory are considered. For just counting files of the directory `dir`, caller can set parameter `files` to NULL.

**Parameters**

\[in] **dir** path to directory, which contains the files \[out] **files** pointer to vector storing the found files (absolute file paths) or NULL if the function is just used for file counting. \[in] **regex** regular expression to match specific files be considered or NULL to find all regular files in directory dir. \[in] **modes** direcotry modes (see enum DirModes)

#### Returns

number of files, which were found. -1 is returned in case of error (e.g. from directory path or missing permissions).

### get\_dir\_files()\[2/2] <a href="#a5800b7dc05dcfb436ec8f8c100757ac7" id="a5800b7dc05dcfb436ec8f8c100757ac7"></a>

int sdi::filesystem::get\_dir\_files

### home\_config\_dir() <a href="#a1eee0f47abbf3108854b4178e194ba45" id="a1eee0f47abbf3108854b4178e194ba45"></a>

const char \\\* home\_config\_dir

return the abloslute path of SDI configuration folder in home directory. (VOS/VOS2: $HOME/share/sdi) (VOS3/Android: $HOME/sdi) (Titus: $HOME, with /sdi as $HOME) This folder holds the SDI default configuration files, which are used, as long as not overloaded by external user configuration package. SDI configuration folder contains files for read access only.

#### Returns

absolute path to SDI default configuration folder (with read-only files)

### home\_config\_file()\[1/2] <a href="#ab8862ea906c088c55072c8ea390c0adc" id="ab8862ea906c088c55072c8ea390c0adc"></a>

std::string sdi::filesystem::home\_config\_file

Appends a relative filename `file` to path returned by [home\_config\_dir()](#a1eee0f47abbf3108854b4178e194ba45)

**Parameters**

\[in] **file** relative filename to append to home\_config\_dir()

#### Returns

file path

{% hint style="info" %}
Use this function for SDI configuration file provided by SDI installation packages and which cannot be overloaded by user configuration packages.
{% endhint %}

### home\_config\_file()\[2/2] <a href="#adebb7050fa15bdc4361a3d24f2c6e2f3" id="adebb7050fa15bdc4361a3d24f2c6e2f3"></a>

string sdi::filesystem::home\_config\_file

### home\_flash\_dir() <a href="#a0de1824701ee8494b54c3c97cb17039b" id="a0de1824701ee8494b54c3c97cb17039b"></a>

const char \\\* home\_flash\_dir

return the absolute path to SDI flash folder in home directory. (VOS/VOS2/VOS3/Android: $HOME/flash/sdi) (Titus: $HOME/flash, with /sdi as $HOME) If subfolders do not already exist, they are created with the first call of this function. The flash folder is the location for files, which require write access by SDI server. Writeable configuration files are synchononized with those files of external user configuration packages by invocation of [init()](#a43918d493a7f56eef174f3c9a82a8e20) function at SDI server startup.

#### Returns

absolute path to SDI flash folder for writeable files

### home\_flash\_file()\[1/2] <a href="#a5748ac7656cef8d6b10941d76eac115d" id="a5748ac7656cef8d6b10941d76eac115d"></a>

std::string sdi::filesystem::home\_flash\_file

Appends a relative filename `file` to path returned by [home\_flash\_dir()](#a0de1824701ee8494b54c3c97cb17039b)

**Parameters**

\[in] **file** relative filename to append to home\_flash\_dir()

#### Returns

file path

### home\_flash\_file()\[2/2] <a href="#aabc728c4e4c0574111826ca732390cca" id="aabc728c4e4c0574111826ca732390cca"></a>

string sdi::filesystem::home\_flash\_file

### home\_lib\_dir() <a href="#a98b1808447b0f9e7848b35156a4c7cc9" id="a98b1808447b0f9e7848b35156a4c7cc9"></a>

const char \\\* home\_lib\_dir

return the abloslute path of lib folder in home directory. (VOS/VOS2/VOS3/Android: $HOME/lib) (Titus: $HOME, with /sdi as $HOME, even libraries are not supported on this platform)

{% hint style="info" %}
This library folder is used for SDI plugins and libraries coming along with SDI download packages.
{% endhint %}

#### Returns

absolute path to home lib folder

### init() <a href="#a43918d493a7f56eef174f3c9a82a8e20" id="a43918d493a7f56eef174f3c9a82a8e20"></a>

void init

This function must be called at startup, before SDI server accesses other functions of the filesystem module. The function internally does the following:

1. It checks the $HOME environment variable. If it is not provided by the system, the function sets $HOME to working directory of SDI server, since this environment variable is referred the most filesystem functions.
2. VOS/VOS2: It calls vos\_wait\_for\_sdicleaner() to wait/synchronize with sdicleaner installed with a previous removal package.
3. VOS/VOS2/Android: It checks for old files of previous SDI server versions and if exist, these files were taken over to new destination, which is expected by the recent SDI server. Old obsolete files of previous SDI server versions were removed.
4. Create subfolders in home flash folder ([home\_flash\_dir()](#a0de1824701ee8494b54c3c97cb17039b)) so that SDI can create files at startup.
5. VOS/VOS2/VOS3: Check for validity of configuration files and delete them to recover them with check\_config\_update() afterwards (see step 9).
6. Android, x86: Check gzip compression of persist partition/folder
7. Read STATUS.CFG (SDI status runtime file). If it does not exist, it is created with defaults. 8 It checks recent SDI mode (passed as parameter *sdi\_mode*) equals mode in STATUS.CFG, for which SDI was previously started. If the mode has changed, an internal factory reset (see function [factory\_reset()](#a12545d574e9182af24a177d1cf453c0c)) is triggered, since home flash directory with previous files of old mode must be wiped.
8. VOS/VOS2/VOS3: it calls check\_config\_update() to synchronize files, which were installed with user configuration packages and which require write access. These files are taken over to home flash directory so that SDI is able have write permissions on them. For this, SDI server holds a registration file with a checksum for each file to detect, if it was overloaded by file of the user configuration package. In addition, after removal of a user configuration package, the associated files are removed again and default files from SDI configuration folder are restored. Titus: It calls check\_config\_update() to checks for installation of user/system configuration files. If installation is pending, the configuration will be processed.
9. Titus: Create installation report for SDI command Get Last Install Error (20-1E).
10. It removes files of software upload folder (see [upload\_install\_dir()](#a34a571792ddd1cbbe291af193597d9a0)), if download packages were uploaded by software upload commands (20-14,20-15,20-16) of a previous SDI startup.
11. Titus: Removes some additional installation related files e.g. report files created by bootloader, GPIO status file. **Parameters**

    \[in] **sdi\_mode** SDI mode, how SDI was started for this runtime, either SDIMode\_Headless or SDIMode\_Standard, see enum SDIMode of sdi\_sysconfig.h

### install\_emv\_config\_package()\[1/2] <a href="#a292b4583cbbd3327c059f32edc6e6168" id="a292b4583cbbd3327c059f32edc6e6168"></a>

unsigned short sdi::filesystem::install\_emv\_config\_package

install an EMV coniguration package as a tarball (uncompressed), which contains EMV configuration files to be installed into EMV flash directory. This is provided by [emv\_flash\_dir()](#a817ffa0e3dd4d66ee5a1717aac4c94b8) and contains EMV configuration files on which ADKEMV requires write access. The function is called during "SW upload 20-14/20-15/20-16" using upload type UPLOAD\_TYPE\_EMV\_CONFIG\_PACKAGE. After all configuration files were installed the function runs required post actions, which are related to the installed files.

**Parameters**

\[in] **emv\_config\_pkg** file path to EMV config update package (tarball)

#### Returns

SDI error code (0x9000 for success, 0x64xx for error)

### install\_emv\_config\_package()\[2/2] <a href="#a7412f8e8dc1ea4a649358a45031df492" id="a7412f8e8dc1ea4a649358a45031df492"></a>

unsigned short sdi::filesystem::install\_emv\_config\_package

### install\_sdi\_plugins() <a href="#af65203b969499e2d36e34c08172a9f30" id="af65203b969499e2d36e34c08172a9f30"></a>

unsigned short install\_sdi\_plugins

install SDI plugins from update package, which was added to SDI update directory (see [sdi\_update\_dir()](#a62f821b6937b4f380d3e22cde31d2920)). Plugins are expected in a specified subfolder "plugin". The function is called wiht command "Check for update (20-1D)" using upload type UPLOAD\_TYPE\_PLUGIN. On Android the update package data is provided and the command is sent by Android Secure Installer. The function copies the external plugin in internal location, which is specified by [ext\_plugin\_dir()](#ae7f61379f5979fbb09444be76ab12a1f). In addition, the function does not allow to install arbitrary files, therefore, it checks, if each found plugin matches the plugin pattern PLUGIN\_PATTERN. After the plugins were overtaken to plugin directory, the plugins are loaded and registered for usage in SDI server. If an external plugin has the same name as an internal plugin (provided with SDI base package, see function [home\_lib\_dir()](#a98b1808447b0f9e7848b35156a4c7cc9)) and shall "overload" it, the internal plugin is unregisted and unloaded before the external plugin installed. Finally, the function stores a backup copy of each plugin to persitent directory (see [sdi\_persist\_dir()](#aeddca685a1e934168171cfef8ef8697e)) to make the installed plugins recoverable for command "Factory Reset (20-22)". For command "Factory Reset (20-22)" the same function is invoked with flag `recover=true`, to restore and install the backup copies from persistent directory.

**Parameters**

\[in] **recover** flag set to true to restore and install the SDI plugins from persistent directory

#### Returns

SDI error code (0x9000 for success, 0x64xx for error)

### install\_user\_configuration() <a href="#ad41174b98a363bf48bbcfc62984939ef" id="ad41174b98a363bf48bbcfc62984939ef"></a>

unsigned short install\_user\_configuration

install user configuration from update package, which was added to SDI update directory (see [sdi\_update\_dir()](#a62f821b6937b4f380d3e22cde31d2920)). The function is called with command "Check for update (20-1D)" using upload type UPLOAD\_TYPE\_CONFIG\_SDIEMV. On Android the update package data is provided and the command is sent by Android Secure Installer. Configuration files are expected in a specified folder structure, whereas other components than SDI (e.g. ADKEMV or ADKSEC) use a path prefix like "emv" or "sec". The function knows the internal location for each file. In addition, the function does not allow to install arbitrary files, therefore, it checks, if the found files are in internal whitelist (see table allowed\_files in [filesystem.cpp](/adk-5.0-programmers-guide/readme/files/dir_44d926a17fc606d3c25449ba60427c63/dir_048f823fee1bfb22502a8732b9a001aa/filesystem_8cpp.md)). After all configuration files were installed the function runs required post actions (if any), which are related to the installed files. Finally, the function stores a backup copy of each file to persitent directory (see [sdi\_persist\_dir()](#aeddca685a1e934168171cfef8ef8697e)) to make the installed files recoverable for command "Factory Reset (20-22)". For command "Factory Reset (20-22)" the same function is invoked with flag `recover=true`, to restore and install the backup copies from persistent directory.

**Parameters**

\[in] **recover** flag set to true to restore and install the configuration files from persistent directory

#### Returns

SDI error code (0x9000 for success, 0x64xx for error)

### log\_config\_dir() <a href="#a1ba2e0d2621785a746e8a2bc2b85bfab" id="a1ba2e0d2621785a746e8a2bc2b85bfab"></a>

const char \\\* log\_config\_dir

return the absolute path to folder for ADK Logging configuration files (VOS/VOS2: /mnt/flash/etc/config/adk-log) (Android: $HOME) (VOS/VOS3: /mnt/appdata/versioned/globalshare/etc/config/adk-log) (Titus: \<ext\_cfg\_dir>/adk-log; \<ext\_cfg\_dir> as provided by [ext\_config\_dir()](#a1518fc71a30bfab59f82fc1a2726c627))

{% hint style="info" %}
Required for SW update on Android. On VOS it is unused.
{% endhint %}

#### Returns

absolute path to HOME for ADK Logging configuration files

### lookup\_config\_file()\[1/2] <a href="#a3f6f1faaea3bfa5fb011c57ec15c7749" id="a3f6f1faaea3bfa5fb011c57ec15c7749"></a>

std::string sdi::filesystem::lookup\_config\_file

lookup a configuration file (read-only) by its relative path `file` and return the absolute path for it. The function looks up the file at first in external configuration folder (provided by [ext\_config\_dir()](#a1518fc71a30bfab59f82fc1a2726c627)). If not found there, the file is searched in SDI default configuration folder (provided by [home\_config\_dir()](#a1eee0f47abbf3108854b4178e194ba45)). The function return an empty string, if the file is not found in one of both locations.

**Parameters**

\[in] **file** relative file path to look up the configuration file (e.g. "sec/sccfg.json")

#### Returns

absolute path of the found configuration file (e.g. "/etc/config/sdi/sec/sccfg.json" or "$HOME/share/sdi/sec/sccfg.json") or an empty string, if the file was not found.

### lookup\_config\_file()\[2/2] <a href="#aae28890912feff7f83d3af43e35b986c" id="aae28890912feff7f83d3af43e35b986c"></a>

string sdi::filesystem::lookup\_config\_file

### move\_file()\[1/2] <a href="#acc0eb80e0e44c07c5f0edfa0763150a5" id="acc0eb80e0e44c07c5f0edfa0763150a5"></a>

bool sdi::filesystem::move\_file

helper function to move file from source `src` to destination `dest`.

**Parameters**

\[in] **src** source file location \[in] **dest** destination file location

#### Returns

true for success, else false for error

### move\_file()\[2/2] <a href="#a5dd1f08cec548612d55ff24e08ae4dcd" id="a5dd1f08cec548612d55ff24e08ae4dcd"></a>

bool sdi::filesystem::move\_file

### nfc\_flash\_dir() <a href="#a3eb6af6e0de2e982c40979a8282da21b" id="a3eb6af6e0de2e982c40979a8282da21b"></a>

const char \\\* nfc\_flash\_dir

return the absolute path for destination folder of ADKNFC configuration files These files require write access, therefore, on Engage these are located in flash. (VOS/VOS2/VOS3: $HOME/flash) (Android: $HOME) (Titus: $HOME, with /sdi as $HOME, even NFC is not supported on this platform)

#### Returns

absolute path to HOME for ADKNFC configuration files

### plugin\_config\_dir() <a href="#a383b7331d5268ea154c61f4ff4eb6ab8" id="a383b7331d5268ea154c61f4ff4eb6ab8"></a>

const char \\\* plugin\_config\_dir

return the absolute path of the folder containing plugin configuration files (with extension cfg, json). VOS3/Android: $HOME/sdi/plugincfg VOS/VOS2: $HOME/share/sdi/plugincfg Titus: $HOME/plugincfg, with /sdi as $HOME (unused so far)

{% hint style="info" %}
Plugin configuration files are installed with SDI plugin package and treaded like internal SDI configuration (as installed with a SDI config package). The reason is these files are installed with system priviledges, thus, we place them to subfolder plugincfg under home configuration directory (see [home\_config\_dir()](#a1eee0f47abbf3108854b4178e194ba45))
{% endhint %}

#### Returns

bsolute path of the folder containing plugin configuration files

### read\_file()\[1/2] <a href="#ad9ecf729e46fab7ad576ed4bc9b4b2cf" id="ad9ecf729e46fab7ad576ed4bc9b4b2cf"></a>

bool sdi::filesystem::read\_file

helper function to read a file into a string

**Parameters**

\[in] **file** name of the file to be read \[out] **data** content of the file that was read

#### Returns

true for success, else false (file couldn't been opened)

### read\_file()\[2/2] <a href="#a141d15606acd013831d2e4ead7765ab5" id="a141d15606acd013831d2e4ead7765ab5"></a>

bool sdi::filesystem::read\_file

### remove\_dir()\[1/2] <a href="#add3a308833cddc7775215c8fc3d1d608" id="add3a308833cddc7775215c8fc3d1d608"></a>

int sdi::filesystem::remove\_dir

helper function to remove a directory recursively with all its content. If *path* already refers a file, the file is removed.

**Parameters**

\[in] **path** path to drectory (or file) to be removed. \[in] **modes** function operation modes, see enum FilesModes

#### Returns

number of files, which were removed. -1 is returned in case of error due to missing directory or file access.

### remove\_dir()\[2/2] <a href="#a8241068dfa57d30c7be7a289815533bf" id="a8241068dfa57d30c7be7a289815533bf"></a>

int sdi::filesystem::remove\_dir

### remove\_files()\[1/2] <a href="#ae04fc0d5bbc079cc49174bbe72ec2d7c" id="ae04fc0d5bbc079cc49174bbe72ec2d7c"></a>

int sdi::filesystem::remove\_files

helper function to remove multiple files. Files to be removed are specified by vector `files`.

**Parameters**

\[in] **files** vector of files to be removed \[in] **modes** function operation modes, see enum FilesModes

#### Returns

number of files, which were removed. -1 is returned in case of error due to missing directory or file access.

### remove\_files()\[2/2] <a href="#a95279759f98284266e220092cbb51508" id="a95279759f98284266e220092cbb51508"></a>

int sdi::filesystem::remove\_files

### remove\_sdi\_plugins() <a href="#ac42ad54eda4b15aa9d9f2d7bda4a55a5" id="ac42ad54eda4b15aa9d9f2d7bda4a55a5"></a>

unsigned short remove\_sdi\_plugins

remove SDI plugins according removal file, which is looked up in SDI update directory (see [sdi\_update\_dir()](#a62f821b6937b4f380d3e22cde31d2920)). The removal file is expected in a specified subfolder "plugin". The function is called with command "Check for update (20-1D)" using upload type UPLOAD\_TYPE\_REMOVE\_PLUGIN. On Android the update package data is provided and the command is sent by Android Secure Installer. Before removal of a plugin, the plugin is unloaded and unregistered for usage in SDI server. If a plugin is removed, which has the same name as an internal plugin in [home\_lib\_dir()](#a98b1808447b0f9e7848b35156a4c7cc9), the internal plugin is loaded and reactivated again. Finally, the function removes the backup copy of each plugin from persitent directory (see [sdi\_persist\_dir()](#aeddca685a1e934168171cfef8ef8697e)) so that command "Factory Reset (20-22)" will no longer recover the plugin.

{% hint style="info" %}
The removal file (remove.json) contains an array 'files' with a filename per plugin to remove. No path prefix is added, the function knows the internal location for each file. The filenames may also contain reguluar expressions to match multiple files to delete. The function does not allow to remove arbitrary files, therefore, it checks, if the regular expression matches one or more plugins is in external plugin folder before the plugin is unregistered, unloaded and removed. If a filename in the removal file does not match any existing plugin, the entry is ignored and it is proceeded with the next one. Example format for removal.json: \[unsupported block]
{% endhint %}

#### Returns

SDI error code (0x9000 for success, 0x64xx for error)

### remove\_user\_configuration() <a href="#abfc178565b6c9e326831f7ef51646744" id="abfc178565b6c9e326831f7ef51646744"></a>

unsigned short remove\_user\_configuration

remove user configuration files according removal file, which is looked up in SDI update directory (see [sdi\_update\_dir()](#a62f821b6937b4f380d3e22cde31d2920)). The function is called with command "Check for update (20-1D)" using upload type UPLOAD\_TYPE\_REMOVE\_CONFIG\_SDIEMV. On Android the update package data is provided and the command is sent by Android Secure Installer. After removal, it runs required post actions (if any), which are related to the removed files. Finally, the function removes the backup copy of each file from persitent directory (see [sdi\_persist\_dir()](#aeddca685a1e934168171cfef8ef8697e)) so that command "Factory Reset (20-22)" will no longer recover the files.

{% hint style="info" %}
The removal file (remove.json) contains an array 'files' with a relative path per file to remove. The same external path representation as in update packages is used and the function knows the internal location for each file. The lines may also contain reguluar expressions to match multiple files to delete. The function does not allow to remove arbitrary files, therefore, it checks, if the found files are in internal whitelist (see table allowed\_files). If a line in the removal file does not match any existing allowed file, the line is ignored and it is proceeded with the next line. Example format for removal.json: \[unsupported block]
{% endhint %}

#### Returns

SDI error code (0x9000 for success, 0x64xx for error)

### sdi\_certstore\_dir() <a href="#abfa13da98e3a50c8c79f55671a6c71be" id="abfa13da98e3a50c8c79f55671a6c71be"></a>

const char \\\* sdi\_certstore\_dir

certificate directory, in which SDI stores certificates (e.g. CAs for TLS (Authex) and device pairing). Usually, the function is required for devices with K81, from which certificates are read before used. (Android: $HOME/certstore) (VOS/VOS2/VOS3: $HOME/flash/sdi/certstore)

#### Returns

ablosulte path to SDI certstore folder

### sdi\_persist\_dir() <a href="#aeddca685a1e934168171cfef8ef8697e" id="aeddca685a1e934168171cfef8ef8697e"></a>

const char \\\* sdi\_persist\_dir

persistant directory to store SDI related update files for default recovery. (Android: /persist/appdata/sdi) (VOS/VOS2/VOS3: empty string) (Titus: $HOME/persist/sys, for system==true $HOME/persist/usr, for system==false) Recently used the following platforms: Android: command "Check for update (20-1D)" and command "Factory Reset (20-22)" Titus: installation for user/system configuration package installation with command "Software Upload (20-14,20-15,20-16)" and command "Factory Reset (20-22)"

#### Returns

ablosulte path to persistent SDI data folder or an empty string, if not supported on platform (e.g. Engage)

### sdi\_update\_dir() <a href="#a62f821b6937b4f380d3e22cde31d2920" id="a62f821b6937b4f380d3e22cde31d2920"></a>

const char \\\* sdi\_update\_dir

read-only source directory for SDI related update package files. (Android: /data/secure/sdi) (VOS/VOS2/VOS3: empty string) (Titus: $HOME/update) Recently used the following platforms: Android: command "Check for update (20-1D)" Titus: installation for user/system configuration package installation with command "Software Upload (20-14,20-15,20-16)"

#### Returns

ablosulte path to update package folder or an empty string, if not supported by plattform (e.g. Engage)

### sys\_remove\_sponsor\_dir() <a href="#a6c67d203b4323cce1f3c274d3f2827ee" id="a6c67d203b4323cce1f3c274d3f2827ee"></a>

const char \\\* sys\_remove\_sponsor\_dir

return absolute path to system directory for removal of sponsor certificates (VOS/VOS2/VOS3/Titus: not supported, an empty string is returned) (Android: /data/secure/sponsor -> used to store the file CRTRESET.SYS to remove the sponsor certificate).

{% hint style="info" %}
This is recently required by SDI server for command 20-1D (Check for Update) with command type 7 (remove sponsor certificate).
{% endhint %}

#### Returns

absolute path to system sponsor removal directory (or an empty string if not supported)

### tmp\_dir() <a href="#a9bc32456ce574dce7e0dbee9f49ed5cd" id="a9bc32456ce574dce7e0dbee9f49ed5cd"></a>

const char \\\* tmp\_dir

return the absolute path to writeable system temp folder. (VOS/VOS2/VOS3: /tmp) (Android: $HOME/tmp) (Titus: $HOME/tmp, with /sdi as $HOME, unused so far)

{% hint style="info" %}
This is recently required by SDI server to store some temporary keys for VCL.
{% endhint %}

#### Returns

absolute path to writeable system temp folder

### upload\_install\_dir() <a href="#a34a571792ddd1cbbe291af193597d9a0" id="a34a571792ddd1cbbe291af193597d9a0"></a>

const char \\\* upload\_install\_dir

return absolute path to upload and installation directory for download packages or certificates (VOS/VOS2: /mnt/flash/install/dl or $HOME/flash/sdi/install) (VOS3: $HOME/flash/sdi/install) (Android: $HOME/install -> e.g. used to install the sponsor certificate) (Titus: $HOME/install, with /sdi as $HOME)

{% hint style="info" %}
This is recently required by SDI server to store download packages with software upload commands (20-14,20-15,20-16) and sponsor certificate installation with command 20-1B.
{% endhint %}

\*\*Parameters\*\*

\[in] **flash** set to true to use home flash folder as installation directory. This parameter is relevant for VOS/VOS2 only, which requires to use home flash directory to store temporary installation files for newer OS versions. This is to reduce RAM usage, since files would be usually stored to /mnt/flash/install/dl, which is a RAM disk.

#### Returns

absolute path to system download package installation directory

### write\_file()\[1/2] <a href="#a0c3b0966ff7d9a48ffef25f5c1715e82" id="a0c3b0966ff7d9a48ffef25f5c1715e82"></a>

bool sdi::filesystem::write\_file

helper function to write a string into a file

**Parameters**

\[in] **file** name of the file to be written \[out] **data** content of the string to be written

#### Returns

true for success, else false (file couldn't been opened)

### write\_file()\[2/2] <a href="#a3a27a49de579060fada2de1f1fcb72c5" id="a3a27a49de579060fada2de1f1fcb72c5"></a>

bool sdi::filesystem::write\_file

### VariableDocumentation <a href="#variable-documentation" id="variable-documentation"></a>

### allowed\_usr\_files <a href="#af64ea9fc2f13d8f3be606630ef0436cd" id="af64ea9fc2f13d8f3be606630ef0436cd"></a>

const struct \[UpdateFiles]\(#structsdi\_1\_1filesystem\_1\_1\_update\_files) allowed\_usr\_files\\\[\\]

**Initial value:**

```cpp
=
   {
   { EMV_PREFIX, EMV_FLASH_CONFIG_FILES, true, LOC_EmvFlashDir, "", (ACT_DisableEpp | ACT_EmvExit), ACT_EmvInitInfo },
   { EMV_PREFIX, EMV_DESIRED_FILE, false, LOC_EmvConfigDir, "", (ACT_DisableEpp | ACT_EmvExitComplete), ACT_EmvInitInfo },
   { SEC_PREFIX, ADKSEC_CONFIG_FILE, false, LOC_SdiExtConfigDir, SEC_PREFIX, ACT_None, ACT_SecInit },
   { "", SDI_CONFIG_FILE, false, LOC_SdiExtConfigDir, "", ACT_None, ACT_None },
   { "", SDI_ACL_FILE, false, LOC_SdiExtConfigDir, "", ACT_None, ACT_AclInit },
   { "", WHITELIST_FILE, false, LOC_SdiFlashDir, "", ACT_None, ACT_WhitelistFile },
   { "", SENSITIVE_TAGS_FILE, false, LOC_SdiFlashDir, "", ACT_None, ACT_None },
   { "", CARD_RANGES_FILE, false, LOC_SdiFlashDir, "", ACT_None, ACT_CardRanges },
   { "", UPDATE_REMOVE_FILE, false, LOC_None, "", ACT_None, ACT_None },
   { LOG_PREFIX, LOG_CONFIG_FILES, true, LOC_LogConfigDir, "", ACT_None, ACT_LogInit },
   { NFC_PREFIX, NFC_WKY_FILES, true, LOC_NfcFlashDir, "", ACT_None, ACT_None },
   { FONT_PREFIX, FONT_FILES, true, LOC_SdiExtFontsDir, "", ACT_None, ACT_None }
   }
```

user configuration files allowed for update and removal

### allowed\_usr\_files\_size <a href="#a8ab079877b3d40867b387ea29bf1db93" id="a8ab079877b3d40867b387ea29bf1db93"></a>

const unsigned allowed\_usr\_files\_size = (sizeof(\[allowed\_usr\_files]\(#af64ea9fc2f13d8f3be606630ef0436cd)) / sizeof(\[allowed\_usr\_files]\(#af64ea9fc2f13d8f3be606630ef0436cd)\\\[0\\]))


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sandbox-docs.verifone.com/adk-5.0-programmers-guide/readme/namespaces/namespacesdi/namespacesdi_1_1filesystem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
