diff options
Diffstat (limited to 'src/io/read.cpp')
-rw-r--r-- | src/io/read.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/io/read.cpp b/src/io/read.cpp index 2ef35cc..3ae5246 100644 --- a/src/io/read.cpp +++ b/src/io/read.cpp @@ -19,17 +19,19 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. #include <fcntl.h> -#include <unistd.h> #include "../strings/astring.hpp" #include "../strings/mstring.hpp" #include "../strings/zstring.hpp" +#include "../strings/literal.hpp" #include "../io/cxxstdio.hpp" #include "../poison.hpp" +namespace tmwa +{ namespace io { ReadFile::ReadFile(FD f) @@ -40,6 +42,10 @@ namespace io : fd(FD::open(name, O_RDONLY | O_CLOEXEC)), start(0), end(0) { } + ReadFile::ReadFile(const DirFd& dir, ZString name) + : fd(dir.open_fd(name, O_RDONLY | O_CLOEXEC)), start(0), end(0) + { + } ReadFile::~ReadFile() { fd.close(); @@ -105,12 +111,12 @@ namespace io if (unhappy) { if (happy) - PRINTF("warning: file contains CR\n"); + FPRINTF(stderr, "warning: file contains CR\n"_fmt); else - PRINTF("warning: file contains bare CR\n"); + FPRINTF(stderr, "warning: file contains bare CR\n"_fmt); } else if (!happy && anything) - PRINTF("warning: file does not contain a trailing newline\n"); + FPRINTF(stderr, "warning: file does not contain a trailing newline\n"_fmt); line = AString(tmp); return anything; } @@ -120,3 +126,4 @@ namespace io return fd != FD(); } } // namespace io +} // namespace tmwa |