blob: 4eb3acc106fe56bf972a181ae94c5fb99818566e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#include "ino-file.h"
#include "SD.h"
struct InoFile_
{
File file;
};
InoFile* inoFile_open(const char* fileName, const char* mode)
{
Serial.println(F("inoFile_open"));
InoFile* iFile;
iFile = (InoFile*)malloc(sizeof(InoFile));
if(!iFile)
return 0;
iFile->file = SD.open(fileName, FILE_READ); /* ARDUINO TODO: add FILE_WRITE capability */
if(!iFile->file)
Serial.println(F("ERROR: SD.open() failed"));
return iFile;
}
int inoFile_close(InoFile* stream)
{
Serial.println(F("inoFile_close"));
stream->file.close();
free(stream);
stream = 0;
return 0;
}
int inoFile_eof(InoFile* stream)
{
//Serial.println(F("inoFile_eof"));
int avail = stream->file.available();
//Serial.print(F("avail: "));
//Serial.println(avail);
if(avail)
{
return 0;
}
Serial.println(F("EOF"));
return 1;
}
int inoFile_getc(InoFile* stream)
{
//Serial.println(F("inoFile_getc"));
return stream->file.read();
}
int inoFile_seek(InoFile* stream, long offset, int origin)
{
Serial.println(F("TODO: inoFile_seek"));
return 0;//TODO: fseek(stream->file, offset, origin);
}
long inoFile_tell(InoFile* stream)
{
Serial.println(F("TODO: inoFile_tell"));
return 0;//TODO: ftell(stream->file);
}
InoFile* inoFile_tmpfile(void)
{
Serial.println(F("inoFile_tmpfile"));
return 0; //TODO: finish inoFile_tmpfile()
}
int inoFile_putc(int ch, InoFile* stream)
{
Serial.println(F("inoFile_putc"));
return 0; //TODO: finish inoFile_putc()
}
int inoFile_printf(InoFile* stream, const char* msg)
{
return stream->file.print(msg);
}
/* kate: bom off; indent-mode cstyle; indent-width 4; replace-trailing-space-save on; */
|