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
Dir.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2015 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "Dir.h" 00018 #include "mbed.h" 00019 #include <errno.h> 00020 00021 00022 Dir::Dir() 00023 : _fs(0), _dir(0) 00024 { 00025 } 00026 00027 Dir::Dir(FileSystem *fs, const char *path) 00028 : _fs(0), _dir(0) 00029 { 00030 open(fs, path); 00031 } 00032 00033 Dir::~Dir() 00034 { 00035 if (_fs) { 00036 close(); 00037 } 00038 } 00039 00040 int Dir::open(FileSystem *fs, const char *path) 00041 { 00042 if (_fs) { 00043 return -EINVAL; 00044 } 00045 00046 _fs = fs; 00047 return _fs->dir_open(&_dir, path); 00048 } 00049 00050 int Dir::close() 00051 { 00052 if (!_fs) { 00053 return -EINVAL; 00054 } 00055 00056 int err = _fs->dir_close(_dir); 00057 _fs = 0; 00058 return err; 00059 } 00060 00061 ssize_t Dir::read(struct dirent *ent) 00062 { 00063 MBED_ASSERT(_fs); 00064 memset(ent, 0, sizeof(struct dirent)); 00065 return _fs->dir_read(_dir, ent); 00066 } 00067 00068 void Dir::seek(off_t offset) 00069 { 00070 MBED_ASSERT(_fs); 00071 return _fs->dir_seek(_dir, offset); 00072 } 00073 00074 off_t Dir::tell() 00075 { 00076 MBED_ASSERT(_fs); 00077 return _fs->dir_tell(_dir); 00078 } 00079 00080 void Dir::rewind() 00081 { 00082 MBED_ASSERT(_fs); 00083 return _fs->dir_rewind(_dir); 00084 } 00085 00086 size_t Dir::size() 00087 { 00088 MBED_ASSERT(_fs); 00089 return _fs->dir_size(_dir); 00090 }
Generated on Tue Jul 12 2022 11:02:23 by
1.7.2