gctl/lib/io/file_io.h

89 lines
3.7 KiB
C
Raw Normal View History

2025-04-23 12:39:44 +08:00
/********************************************************
2024-09-10 15:45:07 +08:00
*
*
*
*
*
*
* Geophysical Computational Tools & Library (GCTL)
*
* Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn)
*
* GCTL is distributed under a dual licensing scheme. You can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 2
* of the License, or (at your option) any later version. You should have
* received a copy of the GNU Lesser General Public License along with this
* program. If not, see <http://www.gnu.org/licenses/>.
*
* If the terms and conditions of the LGPL v.2. would prevent you from using
* the GCTL, please consider the option to obtain a commercial license for a
* fee. These licenses are offered by the GCTL's original author. As a rule,
* licenses are provided "as-is", unlimited in time for a one time fee. Please
* send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget
* to include some description of your company and the realm of its activities.
* Also add information on how to contact you by electronic and paper mail.
******************************************************/
2025-04-23 12:39:44 +08:00
#ifndef _GCTL_FILE_IO_H
#define _GCTL_FILE_IO_H
2024-09-10 15:45:07 +08:00
2025-04-23 12:39:44 +08:00
#include "../core/str.h"
2025-02-06 21:17:24 +08:00
2024-09-10 15:45:07 +08:00
namespace gctl
{
2025-04-23 12:39:44 +08:00
/**
2024-09-10 15:45:07 +08:00
* @brief
*
* @param infile ifstream对象
* @param[in] filename
* @param[in] extension
* @param[in] mode
*/
void open_infile(std::ifstream &infile, std::string filename, std::string extension = "",
std::ios_base::openmode mode = std::ios_base::in);
/**
* @brief
*
* @param infile
* @param[in] filename
* @param[in] exten_pattern 使
* @param[in] mode
*/
void open_matched_infile(std::ifstream &infile, std::string filename, std::string exten_pattern,
std::ios_base::openmode mode = std::ios_base::in);
/**
* @brief
*
* @param outfile ofstream对象
* @param[in] filename
* @param[in] extension
* @param[in] mode
*/
void open_outfile(std::ofstream &outfile, std::string filename, std::string extension = "",
std::ios_base::openmode mode = std::ios_base::out);
/**
* @brief
*
* @param outfile
* @param[in] filename
* @param[in] exten_pattern 使
* @param[in] mode
*/
void open_matched_outfile(std::ofstream &outfile, std::string filename, std::string exten_pattern,
std::ios_base::openmode mode = std::ios_base::out);
2024-12-15 19:15:12 +08:00
/**
* @brief
*
* @param in_str
* @param naked_name
* @param exten_name
*/
void parse_filename(std::string filename, std::string &naked_name, std::string &exten_name);
2025-02-06 21:17:24 +08:00
};
2024-09-10 15:45:07 +08:00
2025-04-23 12:39:44 +08:00
#endif // _GCTL_FILE_IO_H