Developer World
Spresense Arduino Library v3.2.0-77d75a4
Storage.h
Go to the documentation of this file.
1/*
2 * Storage.h - Spresense Arduino Storage library
3 * Copyright 2019 Sony Semiconductor Solutions Corporation
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef __STORAGE_H__
21#define __STORAGE_H__
22
23#ifdef SUBCORE
24#error "Storage library is NOT supported by SubCore."
25#endif
26
43#include <sdk/config.h>
44
45#include <Arduino.h>
46#include <File.h>
47
54
55private:
56 boolean _realpath(char *dest, const char *src, size_t n);
57
58protected:
59 char mountdir[16];
60
61public:
62 StorageClass() : mountdir("") {};
63 StorageClass(const char *str) { strncpy(mountdir, str, 16); };
64
75 File open(const char *filename, uint8_t mode = FILE_READ);
76
87 File open(const String &filename, uint8_t mode = FILE_READ) { return open( filename.c_str(), mode ); }
88
95 boolean exists(const char *filepath);
96
103 boolean exists(const String &filepath) { return exists(filepath.c_str()); }
104
112 boolean mkdir(const char *filepath);
113
121 boolean mkdir(const String &filepath) { return mkdir(filepath.c_str()); }
122
129 boolean remove(const char *filepath);
130
137 boolean remove(const String &filepath) { return remove(filepath.c_str()); }
138
146 boolean rmdir(const char *filepath);
147
155 boolean rmdir(const String &filepath) { return rmdir(filepath.c_str()); }
156
157};
158
159extern StorageClass Storage;
160
163#endif
SPRESENSE Arduino File library.
The File class allows for reading from and writing to individual files on the File System.
Definition: File.h:55
The Storage class provides functions for accessing the storage manipulating its files and directories...
Definition: Storage.h:53
boolean mkdir(const String &filepath)
Create a directory on the Flash.
Definition: Storage.h:121
boolean remove(const char *filepath)
Remove a file from the Flash.
boolean exists(const char *filepath)
Tests whether a file or directory exists on the Flash.
boolean remove(const String &filepath)
Remove a file from the Flash.
Definition: Storage.h:137
boolean exists(const String &filepath)
Tests whether a file or directory exists on the Flash.
Definition: Storage.h:103
File open(const char *filename, uint8_t mode=FILE_READ)
Opens a file on the Flash.
boolean rmdir(const char *filepath)
Remove a directory from the Flash.
File open(const String &filename, uint8_t mode=FILE_READ)
Opens a file on the Flash.
Definition: Storage.h:87
boolean mkdir(const char *filepath)
Create a directory on the Flash.
boolean rmdir(const String &filepath)
Remove a directory from the Flash.
Definition: Storage.h:155
#define FILE_READ
Definition: File.h:47