OpenM++ runtime library (libopenm)
omFile.h
Go to the documentation of this file.
1
5// Copyright (c) 2013-2015 OpenM++
6// This code is licensed under the MIT license (see LICENSE.txt for details)
7
8#ifndef OM_H_FILE_H
9#define OM_H_FILE_H
10
11#include "omHelper.h"
12
13namespace openm
14{
16 extern bool isFileExists(const char * i_filePath);
17
22 extern void openInpStream(std::ifstream & io_inpSt, const char * i_filePath, std::ios_base::openmode i_mode);
23
28 extern void openOutStream(std::ofstream & io_outSt, const char * i_filePath, std::ios_base::openmode i_mode);
29
31 extern const std::string baseDirOf(const std::string & i_path);
32
34 extern const std::string baseDirOf(const char * i_path);
35
37 extern const std::string makeDefaultPath(const char * i_exePath, const char * i_extension);
38
52 std::string const makeFilePath(const char * i_dirPath, const char * i_name, const char * i_extension = nullptr);
53
55 extern const std::string toUtf8(const char * i_byteArr, const char * i_codePageName = nullptr);
56
58 extern const std::string toUtf8(size_t i_size, const char * i_byteArr, const char * i_codePageName = nullptr);
59
61 extern bool isUtf8(size_t i_size, const char * i_byteArr);
62
64 extern const std::string fileToUtf8(const char * i_filePath, const char * i_codePageName = nullptr);
65
67 extern const std::list<std::string> fileToUtf8Lines(const char * i_filePath, const char * i_codePageName = nullptr);
68
69#ifdef _WIN32
75 extern const std::wstring fromUtf8(const char * i_byteArr);
76#endif // _WIN32
77}
78
79#endif // OM_H_FILE_H
openM++ namespace
Definition: log.h:32
const std::string fileToUtf8(const char *i_filePath, const char *i_codePageName=nullptr)
read file and return content as UTF-8 as string
Definition: utf8Convert.cpp:533
const std::string baseDirOf(const std::string &i_path)
return base directory of the path or empty string if path is "." or ".."
const std::string toUtf8(const char *i_byteArr, const char *i_codePageName=nullptr)
convert null-terminated bytes from current user (or specified) code page to UTF-8 string.
Definition: utf8Convert.cpp:406
void openInpStream(std::ifstream &io_inpSt, const char *i_filePath, std::ios_base::openmode i_mode)
open input file stream
bool isFileExists(const char *i_filePath)
return true if file or directory exists
Definition: file.cpp:28
const std::list< std::string > fileToUtf8Lines(const char *i_filePath, const char *i_codePageName=nullptr)
read file, split by linefeed and return content as list of UTF-8 as strings
Definition: utf8Convert.cpp:562
bool isUtf8(size_t i_size, const char *i_byteArr)
return true if bytes are valid UTF-8
Definition: utf8Convert.cpp:441
void openOutStream(std::ofstream &io_outSt, const char *i_filePath, std::ios_base::openmode i_mode)
open output file stream
std::string const makeFilePath(const char *i_dirPath, const char *i_name, const char *i_extension=nullptr)
make path by join directory, file name and specified extension.
Definition: file.cpp:143
const std::string makeDefaultPath(const char *i_exePath, const char *i_extension)
make path from current working directory, executable name and specified extension.
Definition: file.cpp:107
OpenM++ common helper utilities.