xtd 0.2.0
Loading...
Searching...
No Matches
file_info.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "stream_reader.hpp"
7#include "stream_writer.hpp"
8#include <fstream>
9
11namespace xtd {
13 namespace io {
15 class directory_info;
17
42 public:
44
47 static const file_info empty;
49
51
65 explicit file_info(const xtd::string& file_name);
67
69 file_info() = default;
71
73
79 [[nodiscard]] auto directory() const -> xtd::io::directory_info;
80
102 [[nodiscard]] auto directory_name() const -> xtd::string;
103
137 [[nodiscard]] auto exists() const -> bool override;
138
207 [[nodiscard]] auto is_read_only() const -> bool;
276 auto is_read_only(bool value) -> void;
277
331 [[nodiscard]] auto length() const -> xtd::size;
332
366 [[nodiscard]] auto name() const -> xtd::string override;
368
370
411 [[nodiscard]] auto append_text() const -> xtd::io::stream_writer;
412
521 auto copy_to(const xtd::string& dest_file_name) const -> xtd::io::file_info;
631 auto copy_to(const xtd::string& dest_file_name, bool overwrite) const -> xtd::io::file_info;
632
664 [[nodiscard]] auto create() const -> std::ofstream;
665
675 [[nodiscard]] auto create_text() const -> xtd::io::stream_writer;
676
692 auto move_to(const xtd::string& dest_file_name) -> void;
693
709 auto move_to(const xtd::string& dest_file_name, bool overwrite) -> void;
710
721 [[nodiscard]] auto open(std::ios::openmode mode) const -> std::fstream;
722
732 [[nodiscard]] auto open_read() const -> std::ifstream;
733
743 [[nodiscard]] auto open_text() const -> xtd::io::stream_reader;
744
753 [[nodiscard]] auto open_write() const -> std::ofstream;
754
826 auto remove() const -> void override;
827
840 auto replace(const xtd::string& destination_file_name, const xtd::string& destination_backup_file_name) -> file_info;
842 };
843 }
844}
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition directory_info.hpp:130
auto create_text() const -> xtd::io::stream_writer
Creates a std::ofstream that writes a new text file.
static const file_info empty
Represents the uninitialized xtd::io::file_info object. This field is constant.
Definition file_info.hpp:47
auto is_read_only() const -> bool
Gets a value that determines if the current file is read only.
auto exists() const -> bool override
Gets a value indicating whether a file exists.
auto length() const -> xtd::size
Gets the size, in bytes, of the current file.
auto remove() const -> void override
Permanently deletes a file.
auto open_write() const -> std::ofstream
Creates a write-only std::ofstream.
auto open(std::ios::openmode mode) const -> std::fstream
Opens a file in the specified mode.
auto move_to(const xtd::string &dest_file_name) -> void
Moves a specified file to a new location, providing the option to specify a new file name.
auto open_read() const -> std::ifstream
Creates a read-only std::ifstream.
auto directory() const -> xtd::io::directory_info
Gets an instance of the parent directory.
file_info(const xtd::string &file_name)
Initializes a new instance of the xtd::io::file_info class, which acts as a wrapper for a file path.
auto copy_to(const xtd::string &dest_file_name) const -> xtd::io::file_info
Copies an existing file to a new file, disallowing the overwriting of an existing file.
auto name() const -> xtd::string override
Gets the name of the file.
auto open_text() const -> xtd::io::stream_reader
Creates a xtd::io::stream_reader that reads from an existing text file.
auto append_text() const -> xtd::io::stream_writer
Creates a xtd::io::stream_writer that appends text to the file represented by this instance of the xt...
auto directory_name() const -> xtd::string
Gets a string representing the directory's full path.
auto create() const -> std::ofstream
Creates a file.
auto replace(const xtd::string &destination_file_name, const xtd::string &destination_backup_file_name) -> file_info
Replaces the contents of a specified file with the file described by the current xtd::io::file_info o...
Provides the base class for both xtd::io::file_info and xtd::io::directory_info objects.
Definition file_system_info.hpp:87
Implements a xtd::io::text_reader that reads characters from a byte stream.
Definition stream_reader.hpp:28
Implements a xtd::io::text_writer for writing characters to a stream.
Definition stream_writer.hpp:28
Contains xtd::io::file_system_info class.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
@ ios
The operating system is iOS Apple.
Definition platform_id.hpp:36
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::io::stream_reader class.
Contains xtd::io::stream_writer class.