xtd 0.2.0
Loading...
Searching...
No Matches
file_info.h
Go to the documentation of this file.
1
4#pragma once
5#include "file_system_info.h"
6#include "stream_reader.h"
7#include "stream_writer.h"
8#include <fstream>
9
11namespace xtd {
13 namespace io {
15 class directory_info;
17
40 public:
42
45 static const file_info empty;
47
49
63 explicit file_info(const xtd::ustring& file_name);
65
67
74
97
131 bool exists() const override;
132
201 bool is_read_only() const;
270 void is_read_only(bool value);
271
325 size_t length() const;
326
360 xtd::ustring name() const override;
362
364
407
518 xtd::io::file_info copy_to(const xtd::ustring& dest_file_name) const;
630 xtd::io::file_info copy_to(const xtd::ustring& dest_file_name, bool overwrite) const;
631
664 std::ofstream create() const;
665
676
692 void move_to(const xtd::ustring& dest_file_name);
693
709 void move_to(const xtd::ustring& dest_file_name, bool overwrite);
710
721 std::fstream open(std::ios::openmode mode) const;
722
732 std::ifstream open_read() const;
733
744
753 std::ofstream open_write() const;
754
828 void remove() const override;
829
842 file_info replace(const xtd::ustring& destination_file_name, const xtd::ustring& destination_backup_file_name);
844
845 private:
846 file_info() = default;
847 };
848 }
849}
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
Definition directory_info.h:127
Provides static methods for the creation, copying, deletion, moving, and opening of files,...
Definition file_info.h:39
std::ofstream open_write() const
Creates a write-only std::ofstream.
static const file_info empty
Represents the uninitialized xtd::io::file_info object. This field is constant.
Definition file_info.h:45
xtd::ustring name() const override
Gets the name of the file.
xtd::io::file_info copy_to(const xtd::ustring &dest_file_name, bool overwrite) const
Copies an existing file to a new file, allowing the overwriting of an existing file.
std::fstream open(std::ios::openmode mode) const
Opens a file in the specified mode.
std::ofstream create() const
Creates a file.
file_info(const xtd::ustring &file_name)
Initializes a new instance of the xtd::io::file_info class, which acts as a wrapper for a file path.
bool exists() const override
Gets a value indicating whether a file exists.
void move_to(const xtd::ustring &dest_file_name)
Moves a specified file to a new location, providing the option to specify a new file name.
xtd::io::stream_writer append_text() const
Creates a xtd::io::stream_writer that appends text to the file represented by this instance of the xt...
xtd::io::stream_reader open_text() const
Creates a xtd::io::stream_reader that reads from an existing text file.
xtd::io::file_info copy_to(const xtd::ustring &dest_file_name) const
Copies an existing file to a new file, disallowing the overwriting of an existing file.
xtd::io::directory_info directory() const
Gets an instance of the parent directory.
xtd::ustring directory_name() const
Gets a string representing the directory's full path.
size_t length() const
Gets the size, in bytes, of the current file.
std::ifstream open_read() const
Creates a read-only std::ifstream.
xtd::io::stream_writer create_text() const
Creates a std::ofstream that writes a new text file.
bool is_read_only() const
Gets a value that determines if the current file is read only.
file_info replace(const xtd::ustring &destination_file_name, const xtd::ustring &destination_backup_file_name)
Replaces the contents of a specified file with the file described by the current xtd::io::file_info o...
void move_to(const xtd::ustring &dest_file_name, bool overwrite)
Moves a specified file to a new location, providing the options to specify a new file name and to ove...
void is_read_only(bool value)
Sets a value that determines if the current file is read only.
void remove() const override
Permanently deletes a file.
Provides the base class for both xtd::io::file_info and xtd::io::directory_info objects.
Definition file_system_info.h:85
Implements a xtd::io::text_reader that reads characters from a byte stream.
Definition stream_reader.h:26
Implements a xtd::io::text_writer for writing characters to a stream.
Definition stream_writer.h:26
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
Contains xtd::io::file_system_info class.
#define core_export_
Define shared library export.
Definition core_export.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::io::stream_reader class.
Contains xtd::io::stream_writer class.