http://git-wip-us.apache.org/repos/asf/incubator-mynewt-site/blob/bdc0c773/mkdocs/search_index.json ---------------------------------------------------------------------- diff --git a/mkdocs/search_index.json b/mkdocs/search_index.json index 54587e9..13a29a4 100644 --- a/mkdocs/search_index.json +++ b/mkdocs/search_index.json @@ -7,12 +7,12 @@ }, { "location": "/quick-start/", - "text": "Get set\n\n\nApache Mynewt currently offers two ways to quickly get set up, each appealing to different personal preference and familiarity with embedded systems. \n\n\n\n\n\n\n\n\nOption 1:\n All-in-one docker container that bundles Newt tool, developer toolchains and libraries. For this option, go to \nDocker instructions\n\n\n\n\n\n\nOption 2:\n Step-by-step instructions to install the Newt tool, developer toolchains and libraries natively on your computer. For this option, go to \nNative Setup\n\n\n\n\n\n\n\n\nGo!\n\n\nStart a new project as explained under \nCreate Your First Project\n. The core Mynewt OS is automatically downloaded as part of the project installation. \n\n\n\n\n\n\n\n\nWhen you \nCreate Your First Project\n you define a simulated target and run Project Blinky, the Hello World equivalent in the embedded world. \n\n\n\n\n\n\nIf you have one of the supported \nboards\n, you can make real LEDs blink in \nProject Blinky\n. Simply choose the app ropriate tutorial for the board and proceed.\n\n\n\n\n\n\n\n\nAnd More...\n\n\nExplore the \nTutorials\n section for other interesting projects or simply to learn more about Mynewt's capabilities and get familiar with its use.", + "text": "Get set\n\n\nApache Mynewt currently offers two ways to quickly get set up, each appealing to different personal preferences and levels of familiarity with embedded systems. \n\n\n\n\n\n\n\n\nOption 1:\n All-in-one docker container that bundles Newt tool, developer toolchains and libraries. For this option, go to \nDocker instructions\n\n\n\n\n\n\nOption 2:\n Step-by-step instructions to install the Newt tool, developer toolchains and libraries natively on your computer. For this option, go to \nNative Setup\n\n\n\n\n\n\n\n\nGo!\n\n\nStart a new project as explained under \nCreate Your First Project\n. The core Mynewt OS is automatically downloaded as part of the project installation. \n\n\n\n\n\n\n\n\nWhen you \nCreate Your First Project\n you define a simulated target and run Project Blinky, the Hello World equivalent in the embedded world. \n\n\n\n\n\n\nIf you have one of the supported \nboards\n, you can make real LEDs blink in \nProject Blinky\n. Simply cho ose the appropriate tutorial for the board and proceed.\n\n\n\n\n\n\n\n\nAnd More...\n\n\nExplore the \nTutorials\n section for other interesting projects or simply to learn more about Mynewt's capabilities and get familiar with its use.", "title": "Quick Start" }, { "location": "/quick-start/#get-set", - "text": "Apache Mynewt currently offers two ways to quickly get set up, each appealing to different personal preference and familiarity with embedded systems. Option 1: All-in-one docker container that bundles Newt tool, developer toolchains and libraries. For this option, go to Docker instructions Option 2: Step-by-step instructions to install the Newt tool, developer toolchains and libraries natively on your computer. For this option, go to Native Setup", + "text": "Apache Mynewt currently offers two ways to quickly get set up, each appealing to different personal preferences and levels of familiarity with embedded systems. Option 1: All-in-one docker container that bundles Newt tool, developer toolchains and libraries. For this option, go to Docker instructions Option 2: Step-by-step instructions to install the Newt tool, developer toolchains and libraries natively on your computer. For this option, go to Native Setup", "title": "Get set" }, { @@ -4507,7 +4507,7 @@ }, { "location": "/os/modules/fs/fs/fs/", - "text": "File System Abstraction\n\n\nMynewt provides a file system abstraction layer (\nfs/fs\n) to allow client code to be file system agnostic. By accessing the file system via the \nfs/fs\n API, client code can perform file system operations without being tied to a particular implementation. When possible, library code should use the \nfs/fs\n API rather than accessing the underlying file system directly.\n\n\nDescription\n\n\nApplications should aim to minimize the amount of code which depends on a particular file system implementation. When possible, only depend on the \nfs/fs\n package. In the simplest case, the only code which needs to know which file system is in use is the code which initializes the file system. In terms of the Mynewt hierarchy, the \nproject\n package must depend on a specific file system package, while \nlibrary\n packages should only depend on \nfs/fs\n.\n\n\nThe following example illustrates how file system dependencies should be manag ed. In the slinky application, the project is responsible for initializing the file system, so it depends on a concrete file system package called \nfs/nffs\n (Newtron Flash File System). The project explicitly initializes nffs via calls to \nnffs_init()\n, \nnffs_detect()\n and \nnffs_format()\n.\n\n\n# project/slinky/pkg.yml\n\npkg.name: project/slinky\npkg.vers: 0.8.0\npkg.deps:\n - fs/nffs\n\n# [...]\n\n\n\n\n\n// project/slinky/src/main.c\n\n#include \nnffs/nffs.h\n\n\nint\nmain(int argc, char **argv)\n{\n int rc;\n int cnt;\n struct nffs_area_desc descs[NFFS_AREA_MAX];\n\n rc = nffs_init();\n assert(rc == 0);\n\n cnt = NFFS_AREA_MAX;\n rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, \ncnt, descs);\n assert(rc == 0);\n if (nffs_detect(descs) == FS_ECORRUPT) {\n rc = nffs_format(descs);\n assert(rc == 0);\n }\n // [...]\n}\n\n\n\n\n\nOn the other hand, code which uses the file system after it has been initialized need only depend on \nfs/fs\n. For example, the \nlibs/imgmgr\n package is a library which provides firmware upload and download functionality via the use of a file system. This library is only used after the main project has initialized the file system, and therefore only depends on the \nfs/fs\n package.\n\n\n# libs/imgmgr/pkg.yml\npkg.name: libs/imgmgr\npkg.vers: 0.8.0\npkg.deps:\n - fs/fs\n\n# [...]\n\n\n\n\n\nThe \nlibs/imgmgr\n package uses the \nfs/fs\n API for all file system operations.\n\n\nThread Safety\n\n\nAll \nfs/fs\n functions are thread safe.\n\n\nHeader Files\n\n\nAll code which uses the \nfs/fs\n package needs to include the following header:\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nData Structures\n\n\nAll \nfs/fs\n data structures are opaque to client code.\n\n\nstruct fs_file;\nstruct fs_dir;\nstruct fs_dirent;\n\n\n\n\n\nAPI\n\n\nFunctions in \nfs/fs\n that indicate success or failure do so with the following set of return codes:\n\n\n\n\nReturn Codes\n\n\n\n\nThe functions a vailable in this OS feature are:\n\n\n\n\nfs_close\n\n\nfs_closedir\n\n\nfs_dirent_is_dir\n\n\nfs_dirent_name\n\n\nfs_filelen\n\n\nfs_getpos\n\n\nfs_mkdir\n\n\nfs_open\n\n\nfs_opendir\n\n\nfs_read\n\n\nfs_readdir\n\n\nfs_rename\n\n\nfs_seek\n\n\nfs_unlink\n\n\nfs_write\n\n\n\n\nAdditional file system utilities that bundle some of the basic functions above are:\n\n\n\n\nfsutil_read_file\n\n\nfsutil_write_file", + "text": "File System Abstraction\n\n\nMynewt provides a file system abstraction layer (\nfs/fs\n) to allow client code to be file system agnostic. By accessing the file system via the \nfs/fs\n API, client code can perform file system operations without being tied to a particular implementation. When possible, library code should use the \nfs/fs\n API rather than accessing the underlying file system directly.\n\n\nDescription\n\n\nApplications should aim to minimize the amount of code which depends on a particular file system implementation. When possible, only depend on the \nfs/fs\n package. In the simplest case, the only code which needs to know which file system is in use is the code which initializes the file system. In terms of the Mynewt hierarchy, the \napp\n package must depend on a specific file system package, while \nlibrary\n packages should only depend on \nfs/fs\n.\n\n\nThe following example illustrates how file system dependencies should be managed. In the slinky application, the app is responsible for initializing the file system, so it depends on a concrete file system package called \nfs/nffs\n (Newtron Flash File System). The app explicitly initializes nffs via calls to \nnffs_init()\n, \nnffs_detect()\n and \nnffs_format()\n.\n\n\n# repos/apache-mynewt-core/apps/slinky/pkg.yml\n\npkg.name: repos/apache-mynewt-core/apps/slinky\npkg.deps:\n - fs/nffs\n\n# [...]\n\n\n\n\n\n/* repos/apache-mynewt-core/apps/slinky/src/main.c */\n\n\n\n#include \nnffs/nffs.h\n\n\n\nint\n\n\nmain\n(\nint\n \nargc\n, \nchar\n \n**argv\n)\n{\n \nint\n \nrc\n;\n \nint\n \ncnt\n;\n \nstruct\n \nnffs_area_desc\n \ndescs\n[\nNFFS_AREA_MAX\n];\n\n \nrc\n \n=\n \nnffs_init\n();\n \nassert\n(\nrc\n \n==\n \n0\n);\n\n \ncnt\n \n=\n \nNFFS_AREA_MAX\n;\n \nrc\n \n=\n \nflash_area_to_nffs_desc\n(\nFLASH_AREA_NFFS\n, \ncnt\n, \ndescs\n);\n \nassert\n(\nrc\n \n==\n \n0\n);\n \nif\n (\nnffs_detect\n(\ndescs\n) \n==\n \nFS_ECORRUPT\ n) {\n \nrc\n \n=\n \nnffs_format\n(\ndescs\n);\n \nassert\n(\nrc\n \n==\n \n0\n);\n }\n \n// [...]\n\n}\n\n\n\n\n\nOn the other hand, code which uses the file system after it has been initialized need only depend on \nfs/fs\n. For example, the \nlibs/imgmgr\n package is a library which provides firmware upload and download functionality via the use of a file system. This library is only used after the main app has initialized the file system, and therefore only depends on the \nfs/fs\n package.\n\n\n# repos/apache-mynewt-core/libs/imgmgr/pkg.yml\npkg.name: libs/imgmgr\npkg.deps:\n - fs/fs\n\n# [...]\n\n\n\n\n\nThe \nlibs/imgmgr\n package uses the \nfs/fs\n API for all file system operations.\n\n\nThread Safety\n\n\nAll \nfs/fs\n functions are thread safe.\n\n\nHeader Files\n\n\nAll code which uses the \nfs/fs\n package needs to include the following header:\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nData Structures\n\n\nAll \nfs/fs\n data structures are opaque to client code.\n\n\nstruct\n \nfs_file\n;\n\nstruct\n \nfs_dir\n;\n\nstruct\n \nfs_dirent\n;\n\n\n\n\n\nAPI\n\n\nFunctions in \nfs/fs\n that indicate success or failure do so with the following set of return codes:\n\n\n\n\nReturn Codes\n\n\n\n\nThe functions available in this OS feature are:\n\n\n\n\nfs_close\n\n\nfs_closedir\n\n\nfs_dirent_is_dir\n\n\nfs_dirent_name\n\n\nfs_filelen\n\n\nfs_getpos\n\n\nfs_mkdir\n\n\nfs_open\n\n\nfs_opendir\n\n\nfs_read\n\n\nfs_readdir\n\n\nfs_rename\n\n\nfs_seek\n\n\nfs_unlink\n\n\nfs_write\n\n\n\n\nAdditional file system utilities that bundle some of the basic functions above are:\n\n\n\n\nfsutil_read_file\n\n\nfsutil_write_file", "title": "toc" }, { @@ -4517,7 +4517,7 @@ }, { "location": "/os/modules/fs/fs/fs/#description", - "text": "Applications should aim to minimize the amount of code which depends on a particular file system implementation. When possible, only depend on the fs/fs package. In the simplest case, the only code which needs to know which file system is in use is the code which initializes the file system. In terms of the Mynewt hierarchy, the project package must depend on a specific file system package, while library packages should only depend on fs/fs . The following example illustrates how file system dependencies should be managed. In the slinky application, the project is responsible for initializing the file system, so it depends on a concrete file system package called fs/nffs (Newtron Flash File System). The project explicitly initializes nffs via calls to nffs_init() , nffs_detect() and nffs_format() . # project/slinky/pkg.yml\n\npkg.name: project/slinky\npkg.vers: 0.8.0\npkg.deps:\n - fs/nffs\n\n# [...] // project/slinky/src/main.c\n\n#includ e nffs/nffs.h \n\nint\nmain(int argc, char **argv)\n{\n int rc;\n int cnt;\n struct nffs_area_desc descs[NFFS_AREA_MAX];\n\n rc = nffs_init();\n assert(rc == 0);\n\n cnt = NFFS_AREA_MAX;\n rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, cnt, descs);\n assert(rc == 0);\n if (nffs_detect(descs) == FS_ECORRUPT) {\n rc = nffs_format(descs);\n assert(rc == 0);\n }\n // [...]\n} On the other hand, code which uses the file system after it has been initialized need only depend on fs/fs . For example, the libs/imgmgr package is a library which provides firmware upload and download functionality via the use of a file system. This library is only used after the main project has initialized the file system, and therefore only depends on the fs/fs package. # libs/imgmgr/pkg.yml\npkg.name: libs/imgmgr\npkg.vers: 0.8.0\npkg.deps:\n - fs/fs\n\n# [...] The libs/imgmgr package uses the fs/fs API for all file system operations.", + "text": "Applications should aim to minimize the amount of code which depends on a particular file system implementation. When possible, only depend on the fs/fs package. In the simplest case, the only code which needs to know which file system is in use is the code which initializes the file system. In terms of the Mynewt hierarchy, the app package must depend on a specific file system package, while library packages should only depend on fs/fs . The following example illustrates how file system dependencies should be managed. In the slinky application, the app is responsible for initializing the file system, so it depends on a concrete file system package called fs/nffs (Newtron Flash File System). The app explicitly initializes nffs via calls to nffs_init() , nffs_detect() and nffs_format() . # repos/apache-mynewt-core/apps/slinky/pkg.yml\n\npkg.name: repos/apache-mynewt-core/apps/slinky\npkg.deps:\n - fs/nffs\n\n# [...] /* repos/apache-mynewt-c ore/apps/slinky/src/main.c */ #include nffs/nffs.h int main ( int argc , char **argv )\n{\n int rc ;\n int cnt ;\n struct nffs_area_desc descs [ NFFS_AREA_MAX ];\n\n rc = nffs_init ();\n assert ( rc == 0 );\n\n cnt = NFFS_AREA_MAX ;\n rc = flash_area_to_nffs_desc ( FLASH_AREA_NFFS , cnt , descs );\n assert ( rc == 0 );\n if ( nffs_detect ( descs ) == FS_ECORRUPT ) {\n rc = nffs_format ( descs );\n assert ( rc == 0 );\n }\n // [...] \n} On the other hand, code which uses the file system after it has been initialized need only depend on fs/fs . For example, the libs/imgmgr package is a library which provides firmware upload and download functionality via the use of a file system. This library is only used after the main app has initialized the file system, and therefore only depends on the fs/fs package. # repos/apache-mynewt-core/libs/imgmgr/pkg.yml\npkg.name: libs/i mgmgr\npkg.deps:\n - fs/fs\n\n# [...] The libs/imgmgr package uses the fs/fs API for all file system operations.", "title": "Description" }, { @@ -4532,7 +4532,7 @@ }, { "location": "/os/modules/fs/fs/fs/#data-structures", - "text": "All fs/fs data structures are opaque to client code. struct fs_file;\nstruct fs_dir;\nstruct fs_dirent;", + "text": "All fs/fs data structures are opaque to client code. struct fs_file ; struct fs_dir ; struct fs_dirent ;", "title": "Data Structures" }, { @@ -4557,12 +4557,12 @@ }, { "location": "/os/modules/fs/fs/fs_ops/", - "text": "struct fs_ops\n\n\nstruct fs_ops {\n int (*f_open)(const char *filename, uint8_t access_flags,\n struct fs_file **out_file);\n int (*f_close)(struct fs_file *file);\n int (*f_read)(struct fs_file *file, uint32_t len, void *out_data,\n uint32_t *out_len);\n int (*f_write)(struct fs_file *file, const void *data, int len);\n\n int (*f_seek)(struct fs_file *file, uint32_t offset);\n uint32_t (*f_getpos)(const struct fs_file *file);\n int (*f_filelen)(const struct fs_file *file, uint32_t *out_len);\n\n int (*f_unlink)(const char *filename);\n int (*f_rename)(const char *from, const char *to);\n int (*f_mkdir)(const char *path);\n\n int (*f_opendir)(const char *path, struct fs_dir **out_dir);\n int (*f_readdir)(struct fs_dir *dir, struct fs_dirent **out_dirent);\n int (*f_closedir)(struct fs_dir *dir);\n\n int (*f_dirent_name)(const struct fs_dirent *dirent, size_t max_len,\n char *out_name, uint8_t *out _name_len);\n int (*f_dirent_is_dir)(const struct fs_dirent *dirent);\n\n const char *f_name;\n};\n\n\n\n\n\nThis data structure consists of a set of function pointers. Each function pointer corresponds to a file system operation. When registering a file system with the abstraction layer, each function pointer must be pointed at the corresponding routine in the custom file system package.\n\n\nThe required behavior of each corresponding function is documented in the \nfile system abstraction layer API\n.\n\n\nHeader file\n\n\n#include \nfs/fs_if.h", + "text": "struct fs_ops\n\n\nstruct\n \nfs_ops\n {\n \nint\n (\n*f_open\n)(\nconst\n \nchar\n \n*filename\n, \nuint8_t\n \naccess_flags\n,\n \nstruct\n \nfs_file\n \n**out_file\n);\n \nint\n (\n*f_close\n)(\nstruct\n \nfs_file\n \n*file\n);\n \nint\n (\n*f_read\n)(\nstruct\n \nfs_file\n \n*file\n, \nuint32_t\n \nlen\n, \nvoid\n \n*out_data\n,\n \nuint32_t\n \n*out_len\n);\n \nint\n (\n*f_write\n)(\nstruct\n \nfs_file\n \n*file\n, \nconst\n \nvoid\n \n*data\n, \nint\n \nlen\n);\n\n \nint\n (\n*f_seek\n)(\nstruct\n \nfs_file\n \n*file\n, \nuint32_t\n \noffset\n);\n \nuint32_t\n (\n*f_getpos\n)(\nconst\n \nstruct\n \nfs_file\n \n*file\n);\n \nint\n (\n*f_filelen\n)(\nconst\n \nstruct\n \nfs_file\n \n*file\n, \nuint32_t\n \n*out_len\n);\n\n \nint\n (\n*f_unlink\n)(\nconst\n \nchar\n \n*filename\n);\n \nint\n (\n*f_rename\n)(\nconst\n \nchar\n \n*from\n, \nconst\n \nchar\n \n*to\n);\n \nint\n (\n*f_mkdir\n)(\nconst\n \nchar\n \n* path\n);\n\n \nint\n (\n*f_opendir\n)(\nconst\n \nchar\n \n*path\n, \nstruct\n \nfs_dir\n \n**out_dir\n);\n \nint\n (\n*f_readdir\n)(\nstruct\n \nfs_dir\n \n*dir\n, \nstruct\n \nfs_dirent\n \n**out_dirent\n);\n \nint\n (\n*f_closedir\n)(\nstruct\n \nfs_dir\n \n*dir\n);\n\n \nint\n (\n*f_dirent_name\n)(\nconst\n \nstruct\n \nfs_dirent\n \n*dirent\n, \nsize_t\n \nmax_len\n,\n \nchar\n \n*out_name\n, \nuint8_t\n \n*out_name_len\n);\n \nint\n (\n*f_dirent_is_dir\n)(\nconst\n \nstruct\n \nfs_dirent\n \n*dirent\n);\n\n \nconst\n \nchar\n \n*f_name\n;\n};\n\n\n\n\n\nThis data structure consists of a set of function pointers. Each function pointer corresponds to a file system operation. When registering a file system with the abstraction layer, each function pointer must be pointed at the corresponding routine in the custom file system package.\n\n\nThe required behavior of each corresponding function is documented in the \nfile system abstraction layer API\n.\n\n\n Header file\n\n\n#include \nfs/fs_if.h", "title": "struct fs_ops" }, { "location": "/os/modules/fs/fs/fs_ops/#struct-fs95ops", - "text": "struct fs_ops {\n int (*f_open)(const char *filename, uint8_t access_flags,\n struct fs_file **out_file);\n int (*f_close)(struct fs_file *file);\n int (*f_read)(struct fs_file *file, uint32_t len, void *out_data,\n uint32_t *out_len);\n int (*f_write)(struct fs_file *file, const void *data, int len);\n\n int (*f_seek)(struct fs_file *file, uint32_t offset);\n uint32_t (*f_getpos)(const struct fs_file *file);\n int (*f_filelen)(const struct fs_file *file, uint32_t *out_len);\n\n int (*f_unlink)(const char *filename);\n int (*f_rename)(const char *from, const char *to);\n int (*f_mkdir)(const char *path);\n\n int (*f_opendir)(const char *path, struct fs_dir **out_dir);\n int (*f_readdir)(struct fs_dir *dir, struct fs_dirent **out_dirent);\n int (*f_closedir)(struct fs_dir *dir);\n\n int (*f_dirent_name)(const struct fs_dirent *dirent, size_t max_len,\n char *out_name, uint8_t *out_name_len);\n in t (*f_dirent_is_dir)(const struct fs_dirent *dirent);\n\n const char *f_name;\n}; This data structure consists of a set of function pointers. Each function pointer corresponds to a file system operation. When registering a file system with the abstraction layer, each function pointer must be pointed at the corresponding routine in the custom file system package. The required behavior of each corresponding function is documented in the file system abstraction layer API .", + "text": "struct fs_ops {\n int ( *f_open )( const char *filename , uint8_t access_flags ,\n struct fs_file **out_file );\n int ( *f_close )( struct fs_file *file );\n int ( *f_read )( struct fs_file *file , uint32_t len , void *out_data ,\n uint32_t *out_len );\n int ( *f_write )( struct fs_file *file , const void *data , int len );\n\n int ( *f_seek )( struct fs_file *file , uint32_t offset );\n uint32_t ( *f_getpos )( const struct fs_file *file );\n int ( *f_filelen )( const struct fs_file *file , uint32_t *out_len );\n\n int ( *f_unlink )( const char *filename );\n int ( *f_rename )( const char *from , const char *to );\n int ( *f_mkdir )( const char *path );\n\n int ( *f_opendir )( const char *path , struct fs_dir **out_dir );\n int ( *f_readdir )( struct fs_dir *dir , struct fs_dirent **out _dirent );\n int ( *f_closedir )( struct fs_dir *dir );\n\n int ( *f_dirent_name )( const struct fs_dirent *dirent , size_t max_len ,\n char *out_name , uint8_t *out_name_len );\n int ( *f_dirent_is_dir )( const struct fs_dirent *dirent );\n\n const char *f_name ;\n}; This data structure consists of a set of function pointers. Each function pointer corresponds to a file system operation. When registering a file system with the abstraction layer, each function pointer must be pointed at the corresponding routine in the custom file system package. The required behavior of each corresponding function is documented in the file system abstraction layer API .", "title": "struct fs_ops" }, { @@ -4572,17 +4572,17 @@ }, { "location": "/os/modules/fs/fs/fs_close/", - "text": "fs_close\n\n\nint fs_close(struct fs_file *file)\n\n\n\n\n\nCloses the specified file and invalidates the file handle.\n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the file to close\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nNotes\n\n\nIf the file has already been unlinked, and the file has no other open handles, the \nfs_close()\n function causes the file to be deleted from the disk.\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThe below code opens the file \n/settings/config.txt\n for reading, reads some data, and then closes the file.\n\n\nint\nread_config(void)\n{\n struct fs_file *file;\n uint32_t bytes_read;\n uint8_t buf[16];\n int rc;\n\n /* Open the file for reading. */\n rc = fs_open(\n/settings/config.txt\n, FS_ACCESS_READ, \nfile);\n if (rc != 0) {\n return -1;\n }\n\n /* Read up to 16 by tes from the file. */\n rc = fs_read(file, sizeof buf, buf, \nbytes_read);\n if (rc == 0) {\n /* buf now contains up to 16 bytes of file data. */\n console_printf(\nread %u bytes\\n\n, bytes_read)\n }\n\n /* Close the file. */\n fs_close(file);\n\n return rc == 0 ? 0 : -1;\n}", + "text": "fs_close\n\n\nint\n \nfs_close\n(\nstruct\n \nfs_file\n \n*file\n)\n\n\n\n\n\nCloses the specified file and invalidates the file handle.\n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the file to close\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nNotes\n\n\nIf the file has already been unlinked, and the file has no other open handles, the \nfs_close()\n function causes the file to be deleted from the disk.\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThe below code opens the file \n/settings/config.txt\n for reading, reads some data, and then closes the file.\n\n\nint\n\n\nread_config\n(\nvoid\n)\n{\n \nstruct\n \nfs_file\n \n*file\n;\n \nuint32_t\n \nbytes_read\n;\n \nuint8_t\n \nbuf\n[\n16\n];\n \nint\n \nrc\n;\n\n \n/* Open the file for reading. */\n\n \nrc\n \n=\n \nfs_open\n(\n/settings/config.txt\n, \nFS_ACCESS_REA D\n, \nfile\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Read up to 16 bytes from the file. */\n\n \nrc\n \n=\n \nfs_read\n(\nfile\n, \nsizeof\n \nbuf\n, \nbuf\n, \nbytes_read\n);\n \nif\n (\nrc\n \n==\n \n0\n) {\n \n/* buf now contains up to 16 bytes of file data. */\n\n \nconsole_printf\n(\nread %u bytes\\n\n, \nbytes_read\n)\n }\n\n \n/* Close the file. */\n\n \nfs_close\n(\nfile\n);\n\n \nreturn\n \nrc\n \n==\n \n0\n \n?\n \n0\n \n:\n \n-\n1\n;\n}", "title": "fs_close" }, { "location": "/os/modules/fs/fs/fs_close/#fs95close", - "text": "int fs_close(struct fs_file *file) Closes the specified file and invalidates the file handle.", + "text": "int fs_close ( struct fs_file *file ) Closes the specified file and invalidates the file handle.", "title": "fs_close" }, { "location": "/os/modules/fs/fs/fs_close/#arguments", - "text": "Arguments Description file Pointer to the file to close", + "text": "Argument Description file Pointer to the file to close", "title": "Arguments" }, { @@ -4602,22 +4602,22 @@ }, { "location": "/os/modules/fs/fs/fs_close/#example", - "text": "The below code opens the file /settings/config.txt for reading, reads some data, and then closes the file. int\nread_config(void)\n{\n struct fs_file *file;\n uint32_t bytes_read;\n uint8_t buf[16];\n int rc;\n\n /* Open the file for reading. */\n rc = fs_open( /settings/config.txt , FS_ACCESS_READ, file);\n if (rc != 0) {\n return -1;\n }\n\n /* Read up to 16 bytes from the file. */\n rc = fs_read(file, sizeof buf, buf, bytes_read);\n if (rc == 0) {\n /* buf now contains up to 16 bytes of file data. */\n console_printf( read %u bytes\\n , bytes_read)\n }\n\n /* Close the file. */\n fs_close(file);\n\n return rc == 0 ? 0 : -1;\n}", + "text": "The below code opens the file /settings/config.txt for reading, reads some data, and then closes the file. int read_config ( void )\n{\n struct fs_file *file ;\n uint32_t bytes_read ;\n uint8_t buf [ 16 ];\n int rc ;\n\n /* Open the file for reading. */ \n rc = fs_open ( /settings/config.txt , FS_ACCESS_READ , file );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Read up to 16 bytes from the file. */ \n rc = fs_read ( file , sizeof buf , buf , bytes_read );\n if ( rc == 0 ) {\n /* buf now contains up to 16 bytes of file data. */ \n console_printf ( read %u bytes\\n , bytes_read )\n }\n\n /* Close the file. */ \n fs_close ( file );\n\n return rc == 0 ? 0 : - 1 ;\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_closedir/", - "text": "fs_closedir\n\n\nint fs_closedir(struct fs_dir *dir)\n\n\n\n\n\nCloses the specified directory handle. \n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\ndir\n\n\nThe name of the directory to close\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, \ndir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, \ndirent); \n if (rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node\ns name from the file system. */\n rc = fs_dirent_name(dirent, sizeof buf, buf, \nname_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node\ns name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf(\n dir: \n);\n } else {\n console_printf(\nfile: \n);\n }\n console_printf(\n%s\\n\n, buf);\n }\n}", + "text": "fs_closedir\n\n\nint\n \nfs_closedir\n(\nstruct\n \nfs_dir\n \n*dir\n)\n\n\n\n\n\nCloses the specified directory handle. \n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\ndir\n\n\nThe name of the directory to close\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\n\n\ntraverse_dir\n(\nconst\n \nchar\n \n*dirname\n)\n{\n \nstruct\n \nfs_dirent\n \n*dirent\n;\n \nstruct\n \nfs_dir\n \n*dir\n;\n \nchar\n \nbuf\n[\n64\n];\n \nuint8_t\n \nname_len\n;\n \nint\n \nrc\n;\n\n \nrc\n \n=\n \nfs_opendir\n(\ndirname\n, \ndir\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Iterate through the parent directo ry, printing the name of each child\n\n\n * entry. The loop only terminates via a function return.\n\n\n */\n\n \nwhile\n (\n1\n) {\n \n/* Retrieve the next child node. */\n\n \nrc\n \n=\n \nfs_readdir\n(\ndir\n, \ndirent\n); \n \nif\n (\nrc\n \n==\n \nFS_ENOENT\n) {\n \n/* Traversal complete. */\n\n \nreturn\n \n0\n;\n } \nelse\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \n/* Unexpected error. */\n\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Read the child node\ns name from the file system. */\n\n \nrc\n \n=\n \nfs_dirent_name\n(\ndirent\n, \nsizeof\n \nbuf\n, \nbuf\n, \nname_len\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Print the child node\ns name to the console. */\n\n \nif\n (\nfs_dirent_is_dir\n(\ndirent\n)) {\n \nconsole_printf\n(\n dir: \n);\n } \nelse\n {\n \nconsole_printf\n(\nfile: \n);\n }\n \nconsole_printf\n(\n%s\\n\n, \nbuf\n);\n }\n}", "title": "fs_closedir" }, { "location": "/os/modules/fs/fs/fs_closedir/#fs95closedir", - "text": "int fs_closedir(struct fs_dir *dir) Closes the specified directory handle.", + "text": "int fs_closedir ( struct fs_dir *dir ) Closes the specified directory handle.", "title": "fs_closedir" }, { "location": "/os/modules/fs/fs/fs_closedir/#arguments", - "text": "Arguments Description dir The name of the directory to close", + "text": "Argument Description dir The name of the directory to close", "title": "Arguments" }, { @@ -4632,22 +4632,22 @@ }, { "location": "/os/modules/fs/fs/fs_closedir/#example", - "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, dir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, dirent); \n if (rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node s name from the file system. */\n rc = fs_dirent_name(dirent, sizeof buf, buf, name_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node s name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf( dir: );\n } else {\n console_printf( file: );\n }\n console_printf( %s\\n , buf);\n }\n}", + "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int traverse_dir ( const char *dirname )\n{\n struct fs_dirent *dirent ;\n struct fs_dir *dir ;\n char buf [ 64 ];\n uint8_t name_len ;\n int rc ;\n\n rc = fs_opendir ( dirname , dir );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Iterate through the parent directory, printing the name of each child * entry. The loop only terminates via a function return. */ \n while ( 1 ) {\n /* Retrieve the next child node. */ \n rc = fs_readdir ( dir , dirent ); \n if ( rc == FS_ENOENT ) {\n /* Traversal complete. */ \n return 0 ;\n } else if ( rc != 0 ) {\n /* Unexpected error. */ \n return - 1 ;\n }\n\n /* Read the child node s name from the file system. */ \n rc = fs_dirent_name ( dirent , sizeof buf , buf , name_len );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Print the child node s name to the console. */ \n if ( fs_dirent_is_dir ( dirent )) {\n console_printf ( dir: );\n } else {\n console_printf ( file: );\n }\n console_printf ( %s\\n , buf );\n }\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_dirent_is_dir/", - "text": "fs_dirent_is_dir\n\n\nint fs_dirent_is_dir(const struct fs_dirent *dirent)\n\n\n\n\n\nTells you whether the specified directory entry is a sub-directory or a regular file. \n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\ndirent\n\n\nPointer to the directory entry to query\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n1: The entry is a directory\n\n\n0: The entry is a regular file.\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, \ndir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\ n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, \ndirent); \n if (rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node\ns name from the file system. */\n rc = fs_dirent_name(dirent, sizeof buf, buf, \nname_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node\ns name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf(\n dir: \n);\n } else {\n console_printf(\nfile: \n);\n }\n console_printf(\n%s\\n\n, buf);\n }\n}", + "text": "fs_dirent_is_dir\n\n\nint\n \nfs_dirent_is_dir\n(\nconst\n \nstruct\n \nfs_dirent\n \n*dirent\n)\n\n\n\n\n\nTells you whether the specified directory entry is a sub-directory or a regular file. \n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\ndirent\n\n\nPointer to the directory entry to query\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n1: The entry is a directory\n\n\n0: The entry is a regular file.\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\n\n\ntraverse_dir\n(\nconst\n \nchar\n \n*dirname\n)\n{\n \nstruct\n \nfs_dirent\n \n*dirent\n;\n \nstruct\n \nfs_dir\n \n*dir\n;\n \nchar\n \nbuf\n[\n64\n];\n \nuint8_t\n \nname_len\n;\n \nint\n \nrc\n;\n\n \nrc\n \n=\n \nfs_opendir\n(\ndirname\n, \ndir\n);\n \nif\n (\nrc\ n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Iterate through the parent directory, printing the name of each child\n\n\n * entry. The loop only terminates via a function return.\n\n\n */\n\n \nwhile\n (\n1\n) {\n \n/* Retrieve the next child node. */\n\n \nrc\n \n=\n \nfs_readdir\n(\ndir\n, \ndirent\n); \n \nif\n (\nrc\n \n==\n \nFS_ENOENT\n) {\n \n/* Traversal complete. */\n\n \nreturn\n \n0\n;\n } \nelse\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \n/* Unexpected error. */\n\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Read the child node\ns name from the file system. */\n\n \nrc\n \n=\n \nfs_dirent_name\n(\ndirent\n, \nsizeof\n \nbuf\n, \nbuf\n, \nname_len\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Print the child node\ns name to the console. */\n\n \nif\n (\nfs_dirent_is_dir\n(\ndirent\n)) {\n \nconsole_printf\n(\n dir: \n);\n } \nelse\n {\n \nconsole_printf\n(\nfile: \n);\n }\n \nconsole_printf\n(\n%s\\n\n, \nbuf\n);\n }\n}", "title": "fs_dirent_is_dir" }, { "location": "/os/modules/fs/fs/fs_dirent_is_dir/#fs95dirent95is95dir", - "text": "int fs_dirent_is_dir(const struct fs_dirent *dirent) Tells you whether the specified directory entry is a sub-directory or a regular file.", + "text": "int fs_dirent_is_dir ( const struct fs_dirent *dirent ) Tells you whether the specified directory entry is a sub-directory or a regular file.", "title": "fs_dirent_is_dir" }, { "location": "/os/modules/fs/fs/fs_dirent_is_dir/#arguments", - "text": "Arguments Description dirent Pointer to the directory entry to query", + "text": "Argument Description dirent Pointer to the directory entry to query", "title": "Arguments" }, { @@ -4662,22 +4662,22 @@ }, { "location": "/os/modules/fs/fs/fs_dirent_is_dir/#example", - "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, dir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, dirent); \n if (rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node s name from the file system. */\n rc = fs_dirent_name(dirent, sizeof buf, buf, name_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node s name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf( dir: );\n } else {\n console_printf( file: );\n }\n console_printf( %s\\n , buf);\n }\n}", + "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int traverse_dir ( const char *dirname )\n{\n struct fs_dirent *dirent ;\n struct fs_dir *dir ;\n char buf [ 64 ];\n uint8_t name_len ;\n int rc ;\n\n rc = fs_opendir ( dirname , dir );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Iterate through the parent directory, printing the name of each child * entry. The loop only terminates via a function return. */ \n while ( 1 ) {\n /* Retrieve the next child node. */ \n rc = fs_readdir ( dir , dirent ); \n if ( rc == FS_ENOENT ) {\n /* Traversal complete. */ \n return 0 ;\n } else if ( rc != 0 ) {\n /* Unexpected error. */ \n return - 1 ;\n }\n\n /* Read the child node s name from the file system. */ \n rc = fs_dirent_name ( dirent , sizeof buf , buf , name_len );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Print the child node s name to the console. */ \n if ( fs_dirent_is_dir ( dirent )) {\n console_printf ( dir: );\n } else {\n console_printf ( file: );\n }\n console_printf ( %s\\n , buf );\n }\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_dirent_name/", - "text": "fs_dirent_name\n\n\nint fs_dirent_name(const struct fs_dirent *dirent, size_t max_len,\n char *out_name, uint8_t *out_name_len)\n\n\n\n\n\nRetrieves the filename of the specified directory entry. \n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\ndirent\n\n\nPointer to the directory entry to query\n\n\n\n\n\n\nmax_len\n\n\nSize of the \"out_name\" character buffer\n\n\n\n\n\n\nout_name\n\n\nOn success, the entry's filename is written here; always null-terminated\n\n\n\n\n\n\nout_name_len\n\n\nOn success, contains the actual length of the filename, NOT including the null-terminator\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nNotes\n\n\nThe retrieved filename is always null-terminated. To ensure enough space to hold the full filename plus a null-termintor, a destination buffer of size \nfilename-max-length + 1\n should be used.\n\n\nHeader file\n\n\n#include \nfs/f s.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, \ndir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, \ndirent); \n if (rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node\ns name from the file system. */\n rc = fs_dirent_name(dire nt, sizeof buf, buf, \nname_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node\ns name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf(\n dir: \n);\n } else {\n console_printf(\nfile: \n);\n }\n console_printf(\n%s\\n\n, buf);\n }\n}", + "text": "fs_dirent_name\n\n\nint\n \nfs_dirent_name\n(\nconst\n \nstruct\n \nfs_dirent\n \n*dirent\n, \nsize_t\n \nmax_len\n,\n \nchar\n \n*out_name\n, \nuint8_t\n \n*out_name_len\n)\n\n\n\n\n\nRetrieves the filename of the specified directory entry. \n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\ndirent\n\n\nPointer to the directory entry to query\n\n\n\n\n\n\nmax_len\n\n\nSize of the \"out_name\" character buffer\n\n\n\n\n\n\nout_name\n\n\nOn success, the entry's filename is written here; always null-terminated\n\n\n\n\n\n\nout_name_len\n\n\nOn success, contains the actual length of the filename, NOT including the null-terminator\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nNotes\n\n\nThe retrieved filename is always null-terminated. To ensure enough space to hold the full filename plus a null-termintor, a destination buffer of size \nfilename-max-length + 1\n should b e used.\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\n\n\ntraverse_dir\n(\nconst\n \nchar\n \n*dirname\n)\n{\n \nstruct\n \nfs_dirent\n \n*dirent\n;\n \nstruct\n \nfs_dir\n \n*dir\n;\n \nchar\n \nbuf\n[\n64\n];\n \nuint8_t\n \nname_len\n;\n \nint\n \nrc\n;\n\n \nrc\n \n=\n \nfs_opendir\n(\ndirname\n, \ndir\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Iterate through the parent directory, printing the name of each child\n\n\n * entry. The loop only terminates via a function return.\n\n\n */\n\n \nwhile\n (\n1\n) {\n \n/* Retrieve the next child node. */\n\n \nrc\n \n=\n \nfs_readdir\n(\ndir\n, \ndirent\n); \n \nif\n (\nrc\n \n==\n \nFS_ENOENT\n) {\n \n/* Traversal complete. */\n\n \nreturn\n \n0\n;\n } \nelse\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \n/* Unexpected error. */\n\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Read the child node\ns name from the file system. */\n\n \nrc\n \n=\n \nfs_dirent_name\n(\ndirent\n, \nsizeof\n \nbuf\n, \nbuf\n, \nname_len\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Print the child node\ns name to the console. */\n\n \nif\n (\nfs_dirent_is_dir\n(\ndirent\n)) {\n \nconsole_printf\n(\n dir: \n);\n } \nelse\n {\n \nconsole_printf\n(\nfile: \n);\n }\n \nconsole_printf\n(\n%s\\n\n, \nbuf\n);\n }\n}", "title": "fs_dirent_name" }, { "location": "/os/modules/fs/fs/fs_dirent_name/#fs95dirent95name", - "text": "int fs_dirent_name(const struct fs_dirent *dirent, size_t max_len,\n char *out_name, uint8_t *out_name_len) Retrieves the filename of the specified directory entry.", + "text": "int fs_dirent_name ( const struct fs_dirent *dirent , size_t max_len ,\n char *out_name , uint8_t *out_name_len ) Retrieves the filename of the specified directory entry.", "title": "fs_dirent_name" }, { "location": "/os/modules/fs/fs/fs_dirent_name/#arguments", - "text": "Arguments Description dirent Pointer to the directory entry to query max_len Size of the \"out_name\" character buffer out_name On success, the entry's filename is written here; always null-terminated out_name_len On success, contains the actual length of the filename, NOT including the null-terminator", + "text": "Argument Description dirent Pointer to the directory entry to query max_len Size of the \"out_name\" character buffer out_name On success, the entry's filename is written here; always null-terminated out_name_len On success, contains the actual length of the filename, NOT including the null-terminator", "title": "Arguments" }, { @@ -4697,22 +4697,22 @@ }, { "location": "/os/modules/fs/fs/fs_dirent_name/#example", - "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, dir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, dirent); \n if (rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node s name from the file system. */\n rc = fs_dirent_name(dirent, sizeof buf, buf, name_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node s name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf( dir: );\n } else {\n console_printf( file: );\n }\n console_printf( %s\\n , buf);\n }\n}", + "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int traverse_dir ( const char *dirname )\n{\n struct fs_dirent *dirent ;\n struct fs_dir *dir ;\n char buf [ 64 ];\n uint8_t name_len ;\n int rc ;\n\n rc = fs_opendir ( dirname , dir );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Iterate through the parent directory, printing the name of each child * entry. The loop only terminates via a function return. */ \n while ( 1 ) {\n /* Retrieve the next child node. */ \n rc = fs_readdir ( dir , dirent ); \n if ( rc == FS_ENOENT ) {\n /* Traversal complete. */ \n return 0 ;\n } else if ( rc != 0 ) {\n /* Unexpected error. */ \n return - 1 ;\n }\n\n /* Read the child node s name from the file system. */ \n rc = fs_dirent_name ( dirent , sizeof buf , buf , name_len );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Print the child node s name to the console. */ \n if ( fs_dirent_is_dir ( dirent )) {\n console_printf ( dir: );\n } else {\n console_printf ( file: );\n }\n console_printf ( %s\\n , buf );\n }\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_filelen/", - "text": "fs_filelen\n\n\nint fs_filelen(const struct fs_file *file, uint32_t *out_len)\n\n\n\n\n\nRetrieves the current length of the specified open file.\n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the file to query\n\n\n\n\n\n\nout_len\n\n\nOn success, the number of bytes in the file gets written here\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nint\nwrite_config(void)\n{\n struct fs_file *file;\n int rc;\n\n /* If the file doesn\nt exist, create it. If it does exist, truncate it to\n * zero bytes.\n */\n rc = fs_open(\n/settings/config.txt\n, FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE,\n \nfile);\n if (rc == 0) {\n /* Write 5 bytes of data to the file. */\n rc = fs_write(file, \nhello\n, 5);\n if (rc == 0) {\n /* The file should now con tain exactly five bytes. */\n assert(fs_filelen(file) == 5);\n }\n\n /* Close the file. */\n fs_close(file);\n }\n\n return rc == 0 ? 0 : -1;\n}", + "text": "fs_filelen\n\n\nint\n \nfs_filelen\n(\nconst\n \nstruct\n \nfs_file\n \n*file\n, \nuint32_t\n \n*out_len\n)\n\n\n\n\n\nRetrieves the current length of the specified open file.\n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the file to query\n\n\n\n\n\n\nout_len\n\n\nOn success, the number of bytes in the file gets written here\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nint\n\n\nwrite_config\n(\nvoid\n)\n{\n \nstruct\n \nfs_file\n \n*file\n;\n \nint\n \nrc\n;\n\n \n/* If the file doesn\nt exist, create it. If it does exist, truncate it to\n\n\n * zero bytes.\n\n\n */\n\n \nrc\n \n=\n \nfs_open\n(\n/settings/config.txt\n, \nFS_ACCESS_WRITE\n \n|\n \nFS_ACCESS_TRUNCATE\n,\n \nfile\n);\n \nif\n (\nrc\n \n==\n \n0\n) {\n \n/* Write 5 bytes of data to the f ile. */\n\n \nrc\n \n=\n \nfs_write\n(\nfile\n, \nhello\n, \n5\n);\n \nif\n (\nrc\n \n==\n \n0\n) {\n \n/* The file should now contain exactly five bytes. */\n\n \nassert\n(\nfs_filelen\n(\nfile\n) \n==\n \n5\n);\n }\n\n \n/* Close the file. */\n\n \nfs_close\n(\nfile\n);\n }\n\n \nreturn\n \nrc\n \n==\n \n0\n \n?\n \n0\n \n:\n \n-\n1\n;\n}", "title": "fs_filelen" }, { "location": "/os/modules/fs/fs/fs_filelen/#fs95filelen", - "text": "int fs_filelen(const struct fs_file *file, uint32_t *out_len) Retrieves the current length of the specified open file.", + "text": "int fs_filelen ( const struct fs_file *file , uint32_t *out_len ) Retrieves the current length of the specified open file.", "title": "fs_filelen" }, { "location": "/os/modules/fs/fs/fs_filelen/#arguments", - "text": "Arguments Description file Pointer to the file to query out_len On success, the number of bytes in the file gets written here", + "text": "Argument Description file Pointer to the file to query out_len On success, the number of bytes in the file gets written here", "title": "Arguments" }, { @@ -4727,22 +4727,22 @@ }, { "location": "/os/modules/fs/fs/fs_filelen/#example", - "text": "int\nwrite_config(void)\n{\n struct fs_file *file;\n int rc;\n\n /* If the file doesn t exist, create it. If it does exist, truncate it to\n * zero bytes.\n */\n rc = fs_open( /settings/config.txt , FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE,\n file);\n if (rc == 0) {\n /* Write 5 bytes of data to the file. */\n rc = fs_write(file, hello , 5);\n if (rc == 0) {\n /* The file should now contain exactly five bytes. */\n assert(fs_filelen(file) == 5);\n }\n\n /* Close the file. */\n fs_close(file);\n }\n\n return rc == 0 ? 0 : -1;\n}", + "text": "int write_config ( void )\n{\n struct fs_file *file ;\n int rc ;\n\n /* If the file doesn t exist, create it. If it does exist, truncate it to * zero bytes. */ \n rc = fs_open ( /settings/config.txt , FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE ,\n file );\n if ( rc == 0 ) {\n /* Write 5 bytes of data to the file. */ \n rc = fs_write ( file , hello , 5 );\n if ( rc == 0 ) {\n /* The file should now contain exactly five bytes. */ \n assert ( fs_filelen ( file ) == 5 );\n }\n\n /* Close the file. */ \n fs_close ( file );\n }\n\n return rc == 0 ? 0 : - 1 ;\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_getpos/", - "text": "fs_getpos\n\n\nuint32_t fs_getpos(const struct fs_file *file)\n\n\n\n\n\nRetrieves the current read and write position of the specified open file. \n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the file to query\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\nThe file offset, in bytes\n\n\n\n\nNotes\n\n\nIf a file is opened in append mode, its write pointer is always positioned at the end of the file. Calling this function on such a file only indicates the read position.\n\n\nHeader file\n\n\n#include \nfs/fs.h", + "text": "fs_getpos\n\n\nuint32_t\n \nfs_getpos\n(\nconst\n \nstruct\n \nfs_file\n \n*file\n)\n\n\n\n\n\nRetrieves the current read and write position of the specified open file. \n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the file to query\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\nThe file offset, in bytes\n\n\n\n\nNotes\n\n\nIf a file is opened in append mode, its write pointer is always positioned at the end of the file. Calling this function on such a file only indicates the read position.\n\n\nHeader file\n\n\n#include \nfs/fs.h", "title": "fs_getpos" }, { "location": "/os/modules/fs/fs/fs_getpos/#fs95getpos", - "text": "uint32_t fs_getpos(const struct fs_file *file) Retrieves the current read and write position of the specified open file.", + "text": "uint32_t fs_getpos ( const struct fs_file *file ) Retrieves the current read and write position of the specified open file.", "title": "fs_getpos" }, { "location": "/os/modules/fs/fs/fs_getpos/#arguments", - "text": "Arguments Description file Pointer to the file to query", + "text": "Argument Description file Pointer to the file to query", "title": "Arguments" }, { @@ -4762,17 +4762,17 @@ }, { "location": "/os/modules/fs/fs/fs_mkdir/", - "text": "fs_mkdir\n\n\nint fs_mkdir(const char *path)\n\n\n\n\n\nCreates the directory represented by the specified path. \n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\npath\n\n\nThe name of the directory to create\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure.\n\n\n\n\nNotes\n\n\nAll intermediate directories must already exist. The specified path must start with a '/' character.\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example demonstrates creating a series of nested directories.\n\n\nint\ncreate_path(void)\n{\n int rc;\n\n rc = fs_mkdir(\n/data\n);\n if (rc != 0) goto err;\n\n rc = fs_mkdir(\n/data/logs\n);\n if (rc != 0) goto err;\n\n rc = fs_mkdir(\n/data/logs/temperature\n);\n if (rc != 0) goto err;\n\n rc = fs_mkdir(\n/data/logs/temperature/current\n);\n if (rc != 0) goto err;\n\n return 0;\n\nerr:\n /* Clean up the incomplete directory tree, if any. */\n fs_unlink(\n/data\n);\n return -1;\n}", + "text": "fs_mkdir\n\n\nint\n \nfs_mkdir\n(\nconst\n \nchar\n \n*path\n)\n\n\n\n\n\nCreates the directory represented by the specified path. \n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\npath\n\n\nThe name of the directory to create\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure.\n\n\n\n\nNotes\n\n\nAll intermediate directories must already exist. The specified path must start with a '/' character.\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example demonstrates creating a series of nested directories.\n\n\nint\n\n\ncreate_path\n(\nvoid\n)\n{\n \nint\n \nrc\n;\n\n \nrc\n \n=\n \nfs_mkdir\n(\n/data\n);\n \nif\n (\nrc\n \n!=\n \n0\n) \ngoto\n \nerr\n;\n\n \nrc\n \n=\n \nfs_mkdir\n(\n/data/logs\n);\n \nif\n (\nrc\n \n!=\n \n0\n) \ngoto\n \nerr\n;\n\n \nrc\n \n=\n \nfs_mkdir\n(\n/data/logs/temperature\n);\n \nif\n (\nrc\n \n!=\n \n0\n) \ngoto\n \nerr\n; \n\n \nrc\n \n=\n \nfs_mkdir\n(\n/data/logs/temperature/current\n);\n \nif\n (\nrc\n \n!=\n \n0\n) \ngoto\n \nerr\n;\n\n \nreturn\n \n0\n;\n\n\nerr\n:\n \n/* Clean up the incomplete directory tree, if any. */\n\n \nfs_unlink\n(\n/data\n);\n \nreturn\n \n-\n1\n;\n}", "title": "fs_mkdir" }, { "location": "/os/modules/fs/fs/fs_mkdir/#fs95mkdir", - "text": "int fs_mkdir(const char *path) Creates the directory represented by the specified path.", + "text": "int fs_mkdir ( const char *path ) Creates the directory represented by the specified path.", "title": "fs_mkdir" }, { "location": "/os/modules/fs/fs/fs_mkdir/#arguments", - "text": "Arguments Description path The name of the directory to create", + "text": "Argument Description path The name of the directory to create", "title": "Arguments" }, { @@ -4792,17 +4792,17 @@ }, { "location": "/os/modules/fs/fs/fs_mkdir/#example", - "text": "This example demonstrates creating a series of nested directories. int\ncreate_path(void)\n{\n int rc;\n\n rc = fs_mkdir( /data );\n if (rc != 0) goto err;\n\n rc = fs_mkdir( /data/logs );\n if (rc != 0) goto err;\n\n rc = fs_mkdir( /data/logs/temperature );\n if (rc != 0) goto err;\n\n rc = fs_mkdir( /data/logs/temperature/current );\n if (rc != 0) goto err;\n\n return 0;\n\nerr:\n /* Clean up the incomplete directory tree, if any. */\n fs_unlink( /data );\n return -1;\n}", + "text": "This example demonstrates creating a series of nested directories. int create_path ( void )\n{\n int rc ;\n\n rc = fs_mkdir ( /data );\n if ( rc != 0 ) goto err ;\n\n rc = fs_mkdir ( /data/logs );\n if ( rc != 0 ) goto err ;\n\n rc = fs_mkdir ( /data/logs/temperature );\n if ( rc != 0 ) goto err ;\n\n rc = fs_mkdir ( /data/logs/temperature/current );\n if ( rc != 0 ) goto err ;\n\n return 0 ; err :\n /* Clean up the incomplete directory tree, if any. */ \n fs_unlink ( /data );\n return - 1 ;\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_open/", - "text": "fs_open\n\n\nint fs_open(const char *filename, uint8_t access_flags,\n struct fs_file **out_file)\n\n\n\n\n\nOpens a file at the specified path. The result of opening a nonexistent file depends on the access flags specified. All intermediate directories must already exist.\n\n\nThe access flags are best understood by comparing them to their equivalent mode strings accepted by the C standard library function \nfopen()\n.\nThe mode strings passed to \nfopen()\n map to \nfs_open()\n's access flags as follows:\n\n\nr\n - FS_ACCESS_READ\n\nr+\n - FS_ACCESS_READ | FS_ACCESS_WRITE\n\nw\n - FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE\n\nw+\n - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE\n\na\n - FS_ACCESS_WRITE | FS_ACCESS_APPEND\n\na+\n - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_APPEND\n\n\n\n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfilename\n\n\nNull-terminated string indicating the full path o f the file to open\n\n\n\n\n\n\naccess_flags\n\n\nFlags controlling file access; see above table\n\n\n\n\n\n\nout_file\n\n\nOn success, a pointer to the newly-created file handle gets written here\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nNotes\n\n\n\n\n\n\nThere is no concept of current working directory. Therefore all file names should start with '/'.\n\n\n\n\n\n\nAlways close files when you are done using them. If you forget to close a file, the file stays open forever. Do this too many times, and the underlying file system will run out of file handles, causing subsequent open operations to fail. This type of bug is known as a file handle leak or a file descriptor leak.\n\n\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThe below code opens the file \n/settings/config.txt\n for reading, reads some data, and then closes the file.\n\n\nint\nread_config(void)\n{\n struct fs_file *file;\n uint32_t bytes_read;\n uint8_t buf[16];\n int rc;\n\n /* Open the file for reading. */\n rc = fs_open(\n/settings/config.txt\n, FS_ACCESS_READ, \nfile);\n if (rc != 0) {\n return -1;\n }\n\n /* Read up to 16 bytes from the file. */\n rc = fs_read(file, sizeof buf, buf, \nbytes_read);\n if (rc == 0) {\n /* buf now contains up to 16 bytes of file data. */\n console_printf(\nread %u bytes\\n\n, bytes_read)\n }\n\n /* Close the file. */\n fs_close(file);\n\n return rc == 0 ? 0 : -1;\n}", + "text": "fs_open\n\n\nint\n \nfs_open\n(\nconst\n \nchar\n \n*filename\n, \nuint8_t\n \naccess_flags\n,\n \nstruct\n \nfs_file\n \n**out_file\n)\n\n\n\n\n\nOpens a file at the specified path. The result of opening a nonexistent file depends on the access flags specified. All intermediate directories must already exist.\n\n\nThe access flags are best understood by comparing them to their equivalent mode strings accepted by the C standard library function \nfopen()\n.\nThe mode strings passed to \nfopen()\n map to \nfs_open()\n's access flags as follows:\n\n\nr\n - FS_ACCESS_READ\n\nr+\n - FS_ACCESS_READ | FS_ACCESS_WRITE\n\nw\n - FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE\n\nw+\n - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE\n\na\n - FS_ACCESS_WRITE | FS_ACCESS_APPEND\n\na+\n - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_APPEND\n\n\n\n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfilename\n\n\nNull-termin ated string indicating the full path of the file to open\n\n\n\n\n\n\naccess_flags\n\n\nFlags controlling file access; see above table\n\n\n\n\n\n\nout_file\n\n\nOn success, a pointer to the newly-created file handle gets written here\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nNotes\n\n\n\n\n\n\nThere is no concept of current working directory. Therefore all file names should start with '/'.\n\n\n\n\n\n\nAlways close files when you are done using them. If you forget to close a file, the file stays open forever. Do this too many times, and the underlying file system will run out of file handles, causing subsequent open operations to fail. This type of bug is known as a file handle leak or a file descriptor leak.\n\n\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThe below code opens the file \n/settings/config.txt\n for reading, reads some data, and then closes the file.\n\n\nint\n\n\nread_config\n(\nvoid \n)\n{\n \nstruct\n \nfs_file\n \n*file\n;\n \nuint32_t\n \nbytes_read\n;\n \nuint8_t\n \nbuf\n[\n16\n];\n \nint\n \nrc\n;\n\n \n/* Open the file for reading. */\n\n \nrc\n \n=\n \nfs_open\n(\n/settings/config.txt\n, \nFS_ACCESS_READ\n, \nfile\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Read up to 16 bytes from the file. */\n\n \nrc\n \n=\n \nfs_read\n(\nfile\n, \nsizeof\n \nbuf\n, \nbuf\n, \nbytes_read\n);\n \nif\n (\nrc\n \n==\n \n0\n) {\n \n/* buf now contains up to 16 bytes of file data. */\n\n \nconsole_printf\n(\nread %u bytes\\n\n, \nbytes_read\n)\n }\n\n \n/* Close the file. */\n\n \nfs_close\n(\nfile\n);\n\n \nreturn\n \nrc\n \n==\n \n0\n \n?\n \n0\n \n:\n \n-\n1\n;\n}", "title": "fs_open" }, { "location": "/os/modules/fs/fs/fs_open/#fs95open", - "text": "int fs_open(const char *filename, uint8_t access_flags,\n struct fs_file **out_file) Opens a file at the specified path. The result of opening a nonexistent file depends on the access flags specified. All intermediate directories must already exist. The access flags are best understood by comparing them to their equivalent mode strings accepted by the C standard library function fopen() .\nThe mode strings passed to fopen() map to fs_open() 's access flags as follows: r - FS_ACCESS_READ r+ - FS_ACCESS_READ | FS_ACCESS_WRITE w - FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE w+ - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE a - FS_ACCESS_WRITE | FS_ACCESS_APPEND a+ - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_APPEND", + "text": "int fs_open ( const char *filename , uint8_t access_flags ,\n struct fs_file **out_file ) Opens a file at the specified path. The result of opening a nonexistent file depends on the access flags specified. All intermediate directories must already exist. The access flags are best understood by comparing them to their equivalent mode strings accepted by the C standard library function fopen() .\nThe mode strings passed to fopen() map to fs_open() 's access flags as follows: r - FS_ACCESS_READ r+ - FS_ACCESS_READ | FS_ACCESS_WRITE w - FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE w+ - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_TRUNCATE a - FS_ACCESS_WRITE | FS_ACCESS_APPEND a+ - FS_ACCESS_READ | FS_ACCESS_WRITE | FS_ACCESS_APPEND", "title": "fs_open" }, { @@ -4827,22 +4827,22 @@ }, { "location": "/os/modules/fs/fs/fs_open/#example", - "text": "The below code opens the file /settings/config.txt for reading, reads some data, and then closes the file. int\nread_config(void)\n{\n struct fs_file *file;\n uint32_t bytes_read;\n uint8_t buf[16];\n int rc;\n\n /* Open the file for reading. */\n rc = fs_open( /settings/config.txt , FS_ACCESS_READ, file);\n if (rc != 0) {\n return -1;\n }\n\n /* Read up to 16 bytes from the file. */\n rc = fs_read(file, sizeof buf, buf, bytes_read);\n if (rc == 0) {\n /* buf now contains up to 16 bytes of file data. */\n console_printf( read %u bytes\\n , bytes_read)\n }\n\n /* Close the file. */\n fs_close(file);\n\n return rc == 0 ? 0 : -1;\n}", + "text": "The below code opens the file /settings/config.txt for reading, reads some data, and then closes the file. int read_config ( void )\n{\n struct fs_file *file ;\n uint32_t bytes_read ;\n uint8_t buf [ 16 ];\n int rc ;\n\n /* Open the file for reading. */ \n rc = fs_open ( /settings/config.txt , FS_ACCESS_READ , file );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Read up to 16 bytes from the file. */ \n rc = fs_read ( file , sizeof buf , buf , bytes_read );\n if ( rc == 0 ) {\n /* buf now contains up to 16 bytes of file data. */ \n console_printf ( read %u bytes\\n , bytes_read )\n }\n\n /* Close the file. */ \n fs_close ( file );\n\n return rc == 0 ? 0 : - 1 ;\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_opendir/", - "text": "fs_opendir\n\n\nint fs_opendir(const char *path, struct fs_dir **out_dir)\n\n\n\n\n\nOpens the directory at the specified path. The directory's contents can be read with subsequent calls to fs_readdir(). When you are done with the directory handle, close it with fs_closedir(). \n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\npath\n\n\nThe name of the directory to open\n\n\n\n\n\n\nout_dir\n\n\nOn success, points to the directory handle\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS_ENOENT if the specified directory does not exist\n\n\nOther \nFS error code\n on error.\n\n\n\n\nNotes\n\n\n\n\n\n\nUnlinking files from the directory while it is open may result in unpredictable behavior during subsequent calls to \nfs_readdir()\n. New files can be created inside the directory without causing problems.\n\n\n\n\n\n\nAlways close a directory when you are done reading from it. If you forget to close a directory, the di rectory stays open forever. Do this too many times, and the underlying file system will run out of directory handles, causing subsequent open operations to fail. This type of bug is known as a file handle leak or a file descriptor leak.\n\n\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, \ndir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, \ndirent); \n if ( rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node\ns name from the file system. */\n rc = fs_dirent_name(dirent, sizeof buf, buf, \nname_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node\ns name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf(\n dir: \n);\n } else {\n console_printf(\nfile: \n);\n }\n console_printf(\n%s\\n\n, buf);\n }\n}", + "text": "fs_opendir\n\n\nint\n \nfs_opendir\n(\nconst\n \nchar\n \n*path\n, \nstruct\n \nfs_dir\n \n**out_dir\n)\n\n\n\n\n\nOpens the directory at the specified path. The directory's contents can be read with subsequent calls to fs_readdir(). When you are done with the directory handle, close it with fs_closedir(). \n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\npath\n\n\nThe name of the directory to open\n\n\n\n\n\n\nout_dir\n\n\nOn success, points to the directory handle\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS_ENOENT if the specified directory does not exist\n\n\nOther \nFS error code\n on error.\n\n\n\n\nNotes\n\n\n\n\n\n\nUnlinking files from the directory while it is open may result in unpredictable behavior during subsequent calls to \nfs_readdir()\n. New files can be created inside the directory without causing problems.\n\n\n\n\n\n\nAlways close a directory when you are done reading from it. If you forget to close a directory, the directory stays open forever. Do this too many times, and the underlying file system will run out of directory handles, causing subsequent open operations to fail. This type of bug is known as a file handle leak or a file descriptor leak.\n\n\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThis example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle.\n\n\nint\n\n\ntraverse_dir\n(\nconst\n \nchar\n \n*dirname\n)\n{\n \nstruct\n \nfs_dirent\n \n*dirent\n;\n \nstruct\n \nfs_dir\n \n*dir\n;\n \nchar\n \nbuf\n[\n64\n];\n \nuint8_t\n \nname_len\n;\n \nint\n \nrc\n;\n\n \nrc\n \n=\n \nfs_opendir\n(\ndirname\n, \ndir\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Iterate through the parent directory, printing the name of each child\n\n\n * entry. The loop only terminates via a function return.\n\n\n */\n\n \nwhile\n (\n1\n) {\n \n/* Retrieve the next child node. */\n\n \nrc\n \n=\n \nfs_readdir\n(\ndir\n, \ndirent\n); \n \nif\n (\nrc\n \n==\n \nFS_ENOENT\n) {\n \n/* Traversal complete. */\n\n \nreturn\n \n0\n;\n } \nelse\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \n/* Unexpected error. */\n\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Read the child node\ns name from the file system. */\n\n \nrc\n \n=\n \nfs_dirent_name\n(\ndirent\n, \nsizeof\n \nbuf\n, \nbuf\n, \nname_len\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Print the child node\ns name to the console. */\n\n \nif\n (\nfs_dirent_is_dir\n(\ndirent\n)) {\n \nconsole_printf\n(\n dir: \n);\n } \nelse\n {\n \nconsole_printf\n(\nfile: \n);\n }\n \nconsole_printf\n(\n%s\\n\n, \nbuf\n);\n }\n}", "title": "fs_opendir" }, { "location": "/os/modules/fs/fs/fs_opendir/#fs95opendir", - "text": "int fs_opendir(const char *path, struct fs_dir **out_dir) Opens the directory at the specified path. The directory's contents can be read with subsequent calls to fs_readdir(). When you are done with the directory handle, close it with fs_closedir().", + "text": "int fs_opendir ( const char *path , struct fs_dir **out_dir ) Opens the directory at the specified path. The directory's contents can be read with subsequent calls to fs_readdir(). When you are done with the directory handle, close it with fs_closedir().", "title": "fs_opendir" }, { "location": "/os/modules/fs/fs/fs_opendir/#arguments", - "text": "Arguments Description path The name of the directory to open out_dir On success, points to the directory handle", + "text": "Argument Description path The name of the directory to open out_dir On success, points to the directory handle", "title": "Arguments" }, { @@ -4862,22 +4862,22 @@ }, { "location": "/os/modules/fs/fs/fs_opendir/#example", - "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int\ntraverse_dir(const char *dirname)\n{\n struct fs_dirent *dirent;\n struct fs_dir *dir;\n char buf[64];\n uint8_t name_len;\n int rc;\n\n rc = fs_opendir(dirname, dir);\n if (rc != 0) {\n return -1;\n }\n\n /* Iterate through the parent directory, printing the name of each child\n * entry. The loop only terminates via a function return.\n */\n while (1) {\n /* Retrieve the next child node. */\n rc = fs_readdir(dir, dirent); \n if (rc == FS_ENOENT) {\n /* Traversal complete. */\n return 0;\n } else if (rc != 0) {\n /* Unexpected error. */\n return -1;\n }\n\n /* Read the child node s name from the file system. */\n rc = fs_dirent_name(dirent, sizeof buf, buf, name_len);\n if (rc != 0) {\n return -1;\n }\n\n /* Print the child node s name to the console. */\n if (fs_dirent_is_dir(dirent)) {\n console_printf( dir: );\n } else {\n console_printf( file: );\n }\n console_printf( %s\\n , buf);\n }\n}", + "text": "This example iterates through the contents of a directory, printing the name of each child node. When the traversal is complete, the code closes the directory handle. int traverse_dir ( const char *dirname )\n{\n struct fs_dirent *dirent ;\n struct fs_dir *dir ;\n char buf [ 64 ];\n uint8_t name_len ;\n int rc ;\n\n rc = fs_opendir ( dirname , dir );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Iterate through the parent directory, printing the name of each child * entry. The loop only terminates via a function return. */ \n while ( 1 ) {\n /* Retrieve the next child node. */ \n rc = fs_readdir ( dir , dirent ); \n if ( rc == FS_ENOENT ) {\n /* Traversal complete. */ \n return 0 ;\n } else if ( rc != 0 ) {\n /* Unexpected error. */ \n return - 1 ;\n }\n\n /* Read the child node s name from the file system. */ \n rc = fs_dirent_name ( dirent , sizeof buf , buf , name_len );\n if ( rc != 0 ) {\n return - 1 ;\n }\n\n /* Print the child node s name to the console. */ \n if ( fs_dirent_is_dir ( dirent )) {\n console_printf ( dir: );\n } else {\n console_printf ( file: );\n }\n console_printf ( %s\\n , buf );\n }\n}", "title": "Example" }, { "location": "/os/modules/fs/fs/fs_read/", - "text": "fs_read\n\n\nint fs_read(struct fs_file *file, uint32_t len, void *out_data, uint32_t *out_len)\n\n\n\n\n\nReads data from the specified file. If more data is requested than remains in the file, all available data is retrieved and a success code is returned.\n\n\nArguments\n\n\n\n\n\n\n\n\nArguments\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the the file to read from\n\n\n\n\n\n\nlen\n\n\nThe number of bytes to attempt to read\n\n\n\n\n\n\nout_data\n\n\nThe destination buffer to read into\n\n\n\n\n\n\nout_len\n\n\nOn success, the number of bytes actually read gets written here. Pass null if you don't care.\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThe below code opens the file \n/settings/config.txt\n for reading, reads some data, and then closes the file.\n\n\nint\nread_config(void)\n{\n struct fs_file *file;\n uint32_t byt es_read;\n uint8_t buf[16];\n int rc;\n\n /* Open the file for reading. */\n rc = fs_open(\n/settings/config.txt\n, FS_ACCESS_READ, \nfile);\n if (rc != 0) {\n return -1;\n }\n\n /* Read up to 16 bytes from the file. */\n rc = fs_read(file, sizeof buf, buf, \nbytes_read);\n if (rc == 0) {\n /* buf now contains up to 16 bytes of file data. */\n console_printf(\nread %u bytes\\n\n, bytes_read)\n }\n\n /* Close the file. */\n fs_close(file);\n\n return rc == 0 ? 0 : -1;\n}", + "text": "fs_read\n\n\nint\n \nfs_read\n(\nstruct\n \nfs_file\n \n*file\n, \nuint32_t\n \nlen\n, \nvoid\n \n*out_data\n, \nuint32_t\n \n*out_len\n)\n\n\n\n\n\nReads data from the specified file. If more data is requested than remains in the file, all available data is retrieved and a success code is returned.\n\n\nArguments\n\n\n\n\n\n\n\n\nArgument\n\n\nDescription\n\n\n\n\n\n\n\n\n\n\nfile\n\n\nPointer to the the file to read from\n\n\n\n\n\n\nlen\n\n\nThe number of bytes to attempt to read\n\n\n\n\n\n\nout_data\n\n\nThe destination buffer to read into\n\n\n\n\n\n\nout_len\n\n\nOn success, the number of bytes actually read gets written here. Pass null if you don't care.\n\n\n\n\n\n\n\n\nReturned values\n\n\n\n\n0 on success\n\n\nFS error code\n on failure\n\n\n\n\nHeader file\n\n\n#include \nfs/fs.h\n\n\n\n\n\n\nExample\n\n\nThe below code opens the file \n/settings/config.txt\n for reading, reads some data, and then closes the file.\n\n\nint\n\n\nread_config\n(\nvoid \n)\n{\n \nstruct\n \nfs_file\n \n*file\n;\n \nuint32_t\n \nbytes_read\n;\n \nuint8_t\n \nbuf\n[\n16\n];\n \nint\n \nrc\n;\n\n \n/* Open the file for reading. */\n\n \nrc\n \n=\n \nfs_open\n(\n/settings/config.txt\n, \nFS_ACCESS_READ\n, \nfile\n);\n \nif\n (\nrc\n \n!=\n \n0\n) {\n \nreturn\n \n-\n1\n;\n }\n\n \n/* Read up to 16 bytes from the file. */\n\n \nrc\n \n=\n \nfs_read\n(\nfile\n, \nsizeof\n \nbuf\n, \nbuf\n, \nbytes_read\n);\n \nif\n (\nrc\n \n==\n \n0\n) {\n \n/* buf now contains up to 16 bytes of file data. */\n\n \nconsole_printf\n(\nread %u bytes\\n\n, \nbytes_read\n)\n }\n\n \n/* Close the file. */\n\n \nfs_close\n(\nfile\n);\n\n \nreturn\n \nrc\n \n==\n \n0\n \n?\n \n0\n \n:\n \n-\n1\n;\n}", "title": "fs_read" }, { "location": "/os/modules/fs/fs/fs_read/#fs95read", - "text": "int fs_read(struct fs_file *file, uint32_t len, void *out_data, uint32_t *out_len) Reads data from the specified file. If more data is requested than remains in the file, all available data is retrieved and a success code is returned.", + "text": "int fs_read ( struct fs_file *file , uint32_t len , void *out_data , uint32_t *out_len ) Reads data from the specified file. If more data is requested than remains in the file, all available data is retrieved and a success code is returned.", "title": "fs_read" }, { "location": "/os/modules/fs/fs/fs_read/#arguments", - "text": "Arguments Description file Pointer to the the file to read from len The number of bytes to attempt to read out_data The destination buffer to read into out_len On success, the number of bytes actually read gets written here. Pass null if you don't care.", + "text": "Argument Description file Pointer to the the file to read from len The number of bytes to attempt to read out_data The destination buffer to read into out_len On success, the number of bytes actually read gets written here. Pass null if you don't care.", "title": "Arguments" }, { @@ -4892,22 +4892,22 @@ }, { "location": "/os/modules/fs/fs/fs_read/#example", - "text": "The below code opens the file /settings/config.txt for reading, reads some data, and then closes the file. int\nread_config(void)\n{\n struct fs_file *file;\n uint32_t bytes_read;\n uint8_t buf[16];\n int rc;\n\n /* Open the file for reading. */\n rc = fs_open( /settings/config.txt , FS_ACCESS_READ, file);\n if (rc != 0) {\n return -1;
<TRUNCATED>
