#ifndef HI_STRING_H_ #define HI_STRING_H_ #include /** * Concatenate two strings into a buffer. * * If resulting string would be longer than @a buflen - 1, the resulting string * in * @a buf is unchanged. * * @param first Null terminated character string * @param second Null terminated character string */ size_t hi_str_concat_buf(size_t bufsize, char buf[bufsize], const char *first, const char *second); /** * Copy file content to a null terminated string, allocating memory while * reading. * * Can be used for reading the virtual file system, where the file size isn't * known. If @a nmax is non-zero, that amount of bytes is allocated and read at * once. No more than @a nmax bytes is read in that case. * * In all cases, the string is reallocated to match the length before * returning. * * @param filename a complete pathname to the file * @param nread if not null, this will have the total amount bytes read * @param nmax if not 0, this amount of memory in bytes is read and used as * initial allocation */ char *hi_str_from_file(const char *filename, size_t *nread, size_t nmax); /** * Return the first string from @a pathlist that is fully included in @a path. */ const char *hi_str_starts_with(const char path[static 1], size_t listn, const char *pathlist[listn]); /** * Find if @a filename exists at the end of @a path. * * @return 0 if not found, positive if found */ int hi_path_has_filename(const char *path, const char *filename); #endif // HI_STRING_H_