cxong / tinydir

Lightweight, portable and easy to integrate C directory and file reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Reference

cxong opened this issue · comments

commented

A document that describes the public functions, parameters, return values etc.

For widechar:

Define UNICODE and _UNICODE and then include tinydir.h.
Use _tinydir_char_t instead of char for path string. (wchar_t for Windows and char for Linux)
Use TINYDIR_STRING("path") instead of "path". (L"path" for Windows)
Use _tinydir_str[len/cpy/cat/cmp/...] instead of str[len/cpy/cat/cmp]. (Same as _tcs macros)

I'm reading the code, while summarizing the usage.
Predefined limitations:
_TINYDIR_PATH_MAX use OS-related predefined macros or 4096.
But some of them, especially MAX_PATH in Windows, are not the actual limit.

_TINYDIR_FILENAME_MAX 256.
We need to verify if this number is appropriate for all of the OSes.

We also need to verify if the two numbers can be equal to, with or without the ending \0.

struct tinydir_file

  • variable: path, type: _tinydir_char_t[], length limit: 0(NULL), 1 to _TINYDIR_PATH_MAX.
  • variable: name, type: _tinydir_char_t[], length limit: 0(NULL), 1 to _TINYDIR_FILENAME_MAX.
  • variable: extension, type: _tinydir_char_t*.
  • variable: is_dir, type: int, meaning: boolean if this is a directory.
  • variable: is_reg, type: int, meaning: boolean if this is a regular file.
  • variable: is_link, type: int, meaning: boolean if this is a link file. NOT APPLICABLE NOW!

struct tinydir_dir

  • variable: path, type: _tinydir_char_t[], length limit: 0(NULL), 1 to _TINYDIR_PATH_MAX.
  • variable: has_next, type: int, meaning: boolean if there's another file.
  • variable: n_files, type: size_t, meaning: counts of files in the directory.
  • variable: _files, type: tinydir_file*, meaning: pointers to files in the directory.

Supported Operating System (not fully tested):

  • Windows 95+. (Ansi only)
  • Windows 2000+. (Unicode supported)
  • Linux kernel version 2.4.0+. (older version unknown)
  • FreeBSD/OpenBSD/NetBSD. (version unknown)
  • Debian GNU/Hurd. (version unknown)
  • Haiku OS. (version unknown)

Supported Compiler (not fully tested):

  • GCC 2.96+. (older version unknown)
  • Visual Studio 2003+. (older version unknown)
  • Clang & LLVM. (version unknown)
  • MSYS & MinGW. (version unknown)
  • MSYS2 & MinGW-w64. (version unknown)
  • Cygwin & GCC. (version unknown)

Notes:

  • Please use reasonable combination of operating system and compiler.
  • Versions older than above may also be applicable.
  • Although some of the above show version unknown, their latest version should be applicable.