Skip to content

Commit 88316e8

Browse files
author
Cruz Monrreal
authored
Merge pull request #7660 from deepikabhavnani/namespace_fs_update
Remove inclusion of mbed.h and mbed namespace from filesystem code
2 parents 1023280 + 079b751 commit 88316e8

File tree

6 files changed

+28
-27
lines changed

6 files changed

+28
-27
lines changed

features/filesystem/Dir.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
#include "Dir.h"
18-
#include "mbed.h"
1918
#include <errno.h>
2019

20+
namespace mbed {
2121

2222
Dir::Dir()
2323
: _fs(0), _dir(0)
@@ -92,3 +92,5 @@ size_t Dir::size()
9292
MBED_ASSERT(_fs);
9393
return _fs->dir_size(_dir);
9494
}
95+
96+
} // namespace mbed

features/filesystem/File.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
#include "File.h"
18-
#include "mbed.h"
1918
#include <errno.h>
2019

20+
namespace mbed {
2121

2222
File::File()
2323
: _fs(0), _file(0)
@@ -110,3 +110,4 @@ off_t File::size()
110110
return _fs->file_size(_file);
111111
}
112112

113+
} // namespace mbed

features/filesystem/FileSystem.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include "mbed.h"
1817
#include "filesystem/Dir.h"
1918
#include "filesystem/File.h"
2019
#include "filesystem/FileSystem.h"
2120
#include <errno.h>
2221

22+
namespace mbed {
2323

2424
FileSystem::FileSystem(const char *name)
2525
: FileSystemLike(name)
@@ -170,3 +170,5 @@ int FileSystem::open(DirHandle **dir, const char *path) {
170170
*dir = d;
171171
return 0;
172172
}
173+
174+
} // namespace mbed

features/filesystem/fat/FATFileSystem.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@
1919
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
* SOFTWARE.
2121
*/
22-
#include "mbed.h"
23-
2422
#include "diskio.h"
2523
#include "ffconf.h"
26-
#include "mbed_debug.h"
27-
#include "mbed_critical.h"
28-
#include <errno.h>
29-
24+
#include "platform/mbed_debug.h"
25+
#include "platform/mbed_critical.h"
26+
#include "filesystem/mbed_filesystem.h"
3027
#include "FATFileSystem.h"
3128

32-
29+
#include <errno.h>
3330
////// Error handling /////
3431

3532
static int fat_error_remap(FRESULT res)

features/filesystem/fat/FATFileSystem.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@
2929
#include <stdint.h>
3030
#include "PlatformMutex.h"
3131

32-
using namespace mbed;
3332

3433
/**
3534
* FATFileSystem based on ChaN's Fat Filesystem library v0.8
3635
*/
37-
class FATFileSystem : public FileSystem {
36+
class FATFileSystem : public mbed::FileSystem {
3837
public:
3938
/** Lifetime of the FATFileSystem
4039
*
@@ -156,14 +155,14 @@ class FATFileSystem : public FileSystem {
156155
* bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
157156
* @return 0 on success, negative error code on failure
158157
*/
159-
virtual int file_open(fs_file_t *file, const char *path, int flags);
158+
virtual int file_open(mbed::fs_file_t *file, const char *path, int flags);
160159

161160
/** Close a file
162161
*
163162
* @param file File handle
164163
* @return 0 on success, negative error code on failure
165164
*/
166-
virtual int file_close(fs_file_t file);
165+
virtual int file_close(mbed::fs_file_t file);
167166

168167
/** Read the contents of a file into a buffer
169168
*
@@ -172,7 +171,7 @@ class FATFileSystem : public FileSystem {
172171
* @param len The number of bytes to read
173172
* @return The number of bytes read, 0 at end of file, negative error on failure
174173
*/
175-
virtual ssize_t file_read(fs_file_t file, void *buffer, size_t len);
174+
virtual ssize_t file_read(mbed::fs_file_t file, void *buffer, size_t len);
176175

177176
/** Write the contents of a buffer to a file
178177
*
@@ -181,14 +180,14 @@ class FATFileSystem : public FileSystem {
181180
* @param len The number of bytes to write
182181
* @return The number of bytes written, negative error on failure
183182
*/
184-
virtual ssize_t file_write(fs_file_t file, const void *buffer, size_t len);
183+
virtual ssize_t file_write(mbed::fs_file_t file, const void *buffer, size_t len);
185184

186185
/** Flush any buffers associated with the file
187186
*
188187
* @param file File handle
189188
* @return 0 on success, negative error code on failure
190189
*/
191-
virtual int file_sync(fs_file_t file);
190+
virtual int file_sync(mbed::fs_file_t file);
192191

193192
/** Move the file position to a given offset from from a given location
194193
*
@@ -200,65 +199,65 @@ class FATFileSystem : public FileSystem {
200199
* SEEK_END to start from end of file
201200
* @return The new offset of the file
202201
*/
203-
virtual off_t file_seek(fs_file_t file, off_t offset, int whence);
202+
virtual off_t file_seek(mbed::fs_file_t file, off_t offset, int whence);
204203

205204
/** Get the file position of the file
206205
*
207206
* @param file File handle
208207
* @return The current offset in the file
209208
*/
210-
virtual off_t file_tell(fs_file_t file);
209+
virtual off_t file_tell(mbed::fs_file_t file);
211210

212211
/** Get the size of the file
213212
*
214213
* @param file File handle
215214
* @return Size of the file in bytes
216215
*/
217-
virtual off_t file_size(fs_file_t file);
216+
virtual off_t file_size(mbed::fs_file_t file);
218217

219218
/** Open a directory on the filesystem
220219
*
221220
* @param dir Destination for the handle to the directory
222221
* @param path Name of the directory to open
223222
* @return 0 on success, negative error code on failure
224223
*/
225-
virtual int dir_open(fs_dir_t *dir, const char *path);
224+
virtual int dir_open(mbed::fs_dir_t *dir, const char *path);
226225

227226
/** Close a directory
228227
*
229228
* @param dir Dir handle
230229
* @return 0 on success, negative error code on failure
231230
*/
232-
virtual int dir_close(fs_dir_t dir);
231+
virtual int dir_close(mbed::fs_dir_t dir);
233232

234233
/** Read the next directory entry
235234
*
236235
* @param dir Dir handle
237236
* @param ent The directory entry to fill out
238237
* @return 1 on reading a filename, 0 at end of directory, negative error on failure
239238
*/
240-
virtual ssize_t dir_read(fs_dir_t dir, struct dirent *ent);
239+
virtual ssize_t dir_read(mbed::fs_dir_t dir, struct dirent *ent);
241240

242241
/** Set the current position of the directory
243242
*
244243
* @param dir Dir handle
245244
* @param offset Offset of the location to seek to,
246245
* must be a value returned from dir_tell
247246
*/
248-
virtual void dir_seek(fs_dir_t dir, off_t offset);
247+
virtual void dir_seek(mbed::fs_dir_t dir, off_t offset);
249248

250249
/** Get the current position of the directory
251250
*
252251
* @param dir Dir handle
253252
* @return Position of the directory that can be passed to dir_rewind
254253
*/
255-
virtual off_t dir_tell(fs_dir_t dir);
254+
virtual off_t dir_tell(mbed::fs_dir_t dir);
256255

257256
/** Rewind the current position to the beginning of the directory
258257
*
259258
* @param dir Dir handle
260259
*/
261-
virtual void dir_rewind(fs_dir_t dir);
260+
virtual void dir_rewind(mbed::fs_dir_t dir);
262261

263262
private:
264263
FATFS _fs; // Work area (file system object) for logical drive

features/filesystem/littlefs/LittleFileSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#include "mbed.h"
16+
#include "filesystem/mbed_filesystem.h"
1717
#include "LittleFileSystem.h"
1818
#include "errno.h"
1919
extern "C" {

0 commit comments

Comments
 (0)