Nugget
fileio.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2020 PCSX-Redux authors
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 
27 #pragma once
28 
29 #include "common/psxlibc/device.h"
30 #include "common/psxlibc/stdio.h"
31 
32 int psxopen(const char *fname, int mode);
33 int psxlseek(int fd, int offset, int whence);
34 int psxread(int fd, void *buffer, int size);
35 int psxwrite(int fd, void *buffer, int size);
36 int psxclose(int fd);
37 int psxioctl(int fd, int cmd, int arg);
38 void psxexit(int code);
39 int isFileConsole(int fd);
40 int psxgetc(int fd);
41 void psxputc(int c, int fd);
42 
43 void psxputchar(int c);
44 int psxgetchar();
45 char *psxgets(char *storage);
46 void psxputs(const char *str);
47 int psxprintf(const char *msg, ...);
48 void ioabortraw(int code);
49 
50 void setupFileIO(int installTTY);
51 void installStdIo(int installTTY);
52 void reopenStdio();
53 
54 struct Device *findDevice(const char *name);
55 int addDevice(struct Device *);
56 int removeDevice(const char *name);
57 
58 struct File *getFileFromHandle(int fd);
59 struct File *findEmptyFile();
60 
61 const char *splitFilepathAndFindDevice(const char *name, struct Device **device, int *deviceId);
62 
63 extern uint32_t psxerrno;
64 
65 void cdevscan();
66 
67 struct DirEntry *firstFile(const char *filepath, struct DirEntry *entry);
68 struct DirEntry *nextFile(struct DirEntry *entry);
69 int format(const char *deviceName);
70 
71 extern struct File *g_firstFile;
72 
73 int getDeviceStatus();
74 void setDeviceStatus(int deviceStatus);
75 
76 void printInstalledDevices();
77 void ioAbortWithMsg(const char *msg1, const char *msg2);
Definition: device.h:60
Definition: direntry.h:33
Definition: stdio.h:96