MiKTeX 26.5-next
A scalable TeX distribution
Loading...
Searching...
No Matches
FileStream.h
1/* miktex/Core/FileStream.h: -*- C++ -*-
2
3 Copyright (C) 1996-2018 Christian Schenk
4
5 This file is part of the MiKTeX Core Library.
6
7 The MiKTeX Core Library is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2, or
10 (at your option) any later version.
11
12 The MiKTeX Core Library is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with the MiKTeX Core Library; if not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#pragma once
23
24#if !defined(D6DD4259AB704AE6ABDE141135E7C19E)
25#define D6DD4259AB704AE6ABDE141135E7C19E
26
27#include <miktex/Core/config.h>
28
29#include <cstddef>
30#include <cstdio>
31
32#include "Stream.h"
33
34MIKTEX_CORE_BEGIN_NAMESPACE;
35
37class MIKTEXCORETYPEAPI(FileStream) :
38 public Stream
39{
40public:
41 FileStream() = default;
42
43public:
44 FileStream(const FileStream& other) = delete;
45
46public:
47 FileStream& operator= (const FileStream& other) = delete;
48
49public:
50 FileStream(FileStream&& other) = delete;
51
52public:
53 FileStream& operator=(FileStream&& other) = delete;
54
55public:
56 virtual MIKTEXCOREEXPORT MIKTEXTHISCALL ~FileStream() noexcept;
57
58public:
59 FileStream(FILE* file) :
60 file(file)
61 {
62 }
63
64public:
65 MIKTEXCORETHISAPI(void) Attach(FILE* file);
66
68public:
69 MIKTEXCORETHISAPI(void) Close();
70
71public:
72 MIKTEXCORETHISAPI(std::size_t) Read(void* data, std::size_t count) override;
73
74public:
75 MIKTEXCORETHISAPI(void) Write(const void* data, std::size_t count) override;
76
77public:
78 MIKTEXCORETHISAPI(void) Seek(long offset, SeekOrigin origin) override;
79
80public:
81 MIKTEXCORETHISAPI(long) GetPosition() const override;
82
83public:
84 MIKTEXCORETHISAPI(void) SetBinary();
85
86public:
87 FILE* GetFile() const
88 {
89 return file;
90 }
91
92public:
93 FILE* Detach()
94 {
95 FILE* ret = file;
96 file = nullptr;
97 return ret;
98 }
99
100private:
101 FILE* file = nullptr;
102};
103
104MIKTEX_CORE_END_NAMESPACE;
105
106#endif
@ Write
Write access.
Definition File.h:77
@ Read
Read access.
Definition File.h:75