NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_io_utility.h
Go to the documentation of this file.
1/******************************************************************************
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 ******************************************************************************/
10#ifndef __BE_IO_UTILITY_H
11#define __BE_IO_UTILITY_H
12
13#include <sys/stat.h>
14
15#include <cstdint>
16#include <fstream>
17#include <string>
18
19#include <be_error_exception.h>
20#include <be_memory_autoarray.h>
21#include <be_sysdeps.h>
22
23namespace BiometricEvaluation
24{
25 namespace IO
26 {
31 namespace Utility {
32
51 const std::string &directory,
52 const std::string &prefix);
53
68 const std::string &pathname);
69
92 const std::string &sourcepath,
93 const std::string &targetpath,
94 const bool removesource = false);
95
119 const std::string &name);
120
135 uint64_t getFileSize(
136 const std::string &pathname);
137
153 uint64_t
154 sumDirectoryUsage(const std::string &pathname);
155
169 const std::string &pathname);
170
171 /*
172 * Indicate whether a path points to a directory.
173 *
174 * @param[in] pathname
175 * The path to be checked
176 * @return
177 * true if the path is a dir, false otherwise.
178 * @throw Error::StrategyError
179 * An error occurred when using the
180 * underlying storage system, or the
181 * name is malformed.
182 */
184 const std::string &pathname);
185
202 int makePath(const std::string &path, const mode_t mode);
203
225 const std::string &path,
226 std::ios_base::openmode mode = std::ios_base::binary);
227
254 void
256 const uint8_t *data,
257 const size_t size,
258 const std::string &path,
259 std::ios_base::openmode mode = std::ios_base::binary);
260
285 void
287 const Memory::uint8Array data,
288 const std::string &path,
289 std::ios_base::openmode mode = std::ios_base::binary);
290
311 void
313 void *data,
314 size_t size,
315 int pipeFD);
316
334 void
336 Memory::uint8Array &data,
337 int pipeFD);
338
359 void
361 const void *data,
362 size_t size,
363 int pipeFD);
364
383 void
385 const Memory::uint8Array &data,
386 int pipeFD);
387
407 bool
409 const std::string &pathname);
410
430 bool
432 const std::string &pathname);
433
463 std::string
465 const std::string &prefix = "",
466 const std::string &parentDir = "/tmp");
467
500 FILE*
502 std::string &path,
503 const std::string &prefix = "",
504 const std::string &parentDir = "/tmp");
505
520 uint64_t
522 const std::string &path);
523
535 uint64_t
537 const Memory::uint8Array &textBuffer);
538 }
539 }
540}
541#endif /* __BE_IO_UTILITY_H */
bool isWritable(const std::string &pathname)
Determine if the real user has write access permissions to this file.
bool isReadable(const std::string &pathname)
Determine if the real user has read access permissions to this file.
void readPipe(void *data, size_t size, int pipeFD)
Read from an open pipe into a buffer.
std::string createTemporaryFile(const std::string &prefix="", const std::string &parentDir="/tmp")
Create a temporary file.
uint64_t getFileSize(const std::string &pathname)
Get the size of a file.
bool fileExists(const std::string &pathname)
Indicate whether a file exists.
void copyDirectoryContents(const std::string &sourcepath, const std::string &targetpath, const bool removesource=false)
Copy the contents of a directory, optionally deleting the source directory contents when done.
void setAsideName(const std::string &name)
Set aside a file or directory name.
Memory::uint8Array readFile(const std::string &path, std::ios_base::openmode mode=std::ios_base::binary)
Read the contents of a file into an 8-bit AutoArray.
uint64_t countLines(const std::string &path)
Count the number of newline characters in a text file.
int makePath(const std::string &path, const mode_t mode)
Create an entire directory tree.
void writeFile(const uint8_t *data, const size_t size, const std::string &path, std::ios_base::openmode mode=std::ios_base::binary)
Write the contents of a buffer to a file.
uint64_t sumDirectoryUsage(const std::string &pathname)
Get the sum of the sizes of all files and directories in a given path.
void removeDirectory(const std::string &directory, const std::string &prefix)
Remove a directory using directory name and parent pathname.
bool pathIsDirectory(const std::string &pathname)
void writePipe(const void *data, size_t size, int pipeFD)
Write the contents of a buffer to a pipe.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...