Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more
FileSystem.cpp
00001 00002 /* mbed Microcontroller Library 00003 * Copyright (c) 2006-2013 ARM Limited 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "mbed.h" 00019 #include "filesystem/FileSystem.h" 00020 #include <errno.h> 00021 00022 00023 FileSystem::FileSystem(const char *name) 00024 : FileBase(name, FileSystemPathType) 00025 { 00026 } 00027 00028 int FileSystem::file_sync(fs_file_t file) 00029 { 00030 return 0; 00031 } 00032 00033 int FileSystem::file_isatty(fs_file_t file) 00034 { 00035 return false; 00036 } 00037 00038 off_t FileSystem::file_tell(fs_file_t file) 00039 { 00040 return file_seek(file, 0, SEEK_CUR); 00041 } 00042 00043 void FileSystem::file_rewind(fs_file_t file) 00044 { 00045 file_seek(file, 0, SEEK_SET); 00046 } 00047 00048 size_t FileSystem::file_size(fs_file_t file) 00049 { 00050 off_t off = file_tell(file); 00051 size_t size = file_seek(file, 0, SEEK_END); 00052 file_seek(file, off, SEEK_SET); 00053 return size; 00054 } 00055 00056 int FileSystem::mkdir(const char *path, mode_t mode) 00057 { 00058 return -ENOSYS; 00059 } 00060 00061 int FileSystem::dir_open(fs_dir_t *dir, const char *path) 00062 { 00063 return -ENOSYS; 00064 } 00065 00066 int FileSystem::dir_close(fs_dir_t dir) 00067 { 00068 return -ENOSYS; 00069 } 00070 00071 ssize_t FileSystem::dir_read(fs_dir_t dir, struct dirent *ent) 00072 { 00073 return -ENOSYS; 00074 } 00075 00076 void FileSystem::dir_seek(fs_dir_t dir, off_t offset) 00077 { 00078 } 00079 00080 off_t FileSystem::dir_tell(fs_dir_t dir) 00081 { 00082 return 0; 00083 } 00084 00085 void FileSystem::dir_rewind(fs_dir_t dir) 00086 { 00087 // Note, the may not satisfy rewind on all filesystems 00088 dir_seek(dir, 0); 00089 } 00090 00091 size_t FileSystem::dir_size(fs_dir_t dir) 00092 { 00093 off_t off = dir_tell(dir); 00094 size_t size = 0; 00095 struct dirent *ent = new struct dirent; 00096 00097 dir_rewind(dir); 00098 while (true) { 00099 int res = dir_read(dir, ent); 00100 if (res <= 0) { 00101 break; 00102 } 00103 00104 size += 1; 00105 } 00106 dir_seek(dir, off); 00107 00108 delete ent; 00109 return size; 00110 } 00111
Generated on Tue Jul 12 2022 11:02:24 by
1.7.2