-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFiles.cpp
95 lines (85 loc) · 2.43 KB
/
Files.cpp
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
93
94
95
//#######################################################################
// Module: Files.cpp
// Descrption: SIFFS file management
// Creator: markeby
// Date: 8/16/2024
//#######################################################################
#include <Arduino.h>
#include "Files.h"
using namespace std;
//#######################################################################
FILES_C::FILES_C () : Ready(false)
{
this->Ready = false;
FileList.clear ();
NumberFiles = 0;
}
//#######################################################################
bool FILES_C::Begin ()
{
if ( SD.begin() )
{
if ( SD.cardType () != CARD_NONE )
{
if ( this->FetchDirectory () )
return (true);
}
else
{
printf ("\t**** No SD card found\n");
return (true);
}
}
else
{
printf ("\t**** SD card failed to initialize\n");
return (true);
}
Ready = true;
return (false);
}
//#######################################################################
bool FILES_C::FetchDirectory ()
{
File root = SD.open ("/");
if ( !root )
{
printf ("\t**** failed to open directory");
return (true);
}
File file;
while ( (file = root.openNextFile ()) )
{
if ( !file.isDirectory () )
{
String st = file.name ();
if ( st.equals("WPSettings.dat") )
continue;
if ( st.equals("IndexerVolumeGuid") )
continue;
this->FileList.push_back (st);
}
}
this->NumberFiles = this->FileList.size ();
if ( this->NumberFiles == 0 )
return (true);
return (false);
}
//#######################################################################
void FILES_C::ListDirectory ()
{
int z = 0;
if ( this-Ready )
{
printf ("\n\t===============================\n");
printf ("\t=========== FILES =============\n");
for ( auto const& zs : FileList )
{
String st = zs;
printf ("\t%-2d %s\n", ++z, st.c_str ());
}
}
printf ("\n");
}
//#######################################################################
FILES_C Files;