]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/d/dmd/root/file.h
d: Merge upstream dmd 7132b3537
[thirdparty/gcc.git] / gcc / d / dmd / root / file.h
CommitLineData
b4c522fa 1
a3b38b77 2/* Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved
b4c522fa
IB
3 * http://www.digitalmars.com
4 * Distributed under the Boost Software License, Version 1.0.
5 * http://www.boost.org/LICENSE_1_0.txt
6 * https://github.com/dlang/dmd/blob/master/src/dmd/root/file.h
7 */
8
9#pragma once
10
f9ab59ff 11#include "dsystem.h"
b4c522fa
IB
12#include "array.h"
13
14typedef Array<struct File *> Files;
15
16struct FileName;
17
18struct File
19{
20 int ref; // != 0 if this is a reference to someone else's buffer
21 unsigned char *buffer; // data for our file
22 size_t len; // amount of data in buffer[]
23
24 FileName *name; // name of our file
25
26 File(const char *);
27 static File *create(const char *);
28 File(const FileName *);
29 ~File();
30
31 const char *toChars();
32
33 /* Read file, return true if error
34 */
35
36 bool read();
37
38 /* Write file, return true if error
39 */
40
41 bool write();
42
43 /* Set buffer
44 */
45
46 void setbuffer(void *buffer, size_t len)
47 {
48 this->buffer = (unsigned char *)buffer;
49 this->len = len;
50 }
51
52 void remove(); // delete file
53};