123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #include "platform/FilePath.h"
- namespace mbed {
- FilePath::FilePath(const char *file_path) : file_name(NULL), fb(NULL)
- {
-
- file_path += strspn(file_path, "/");
- const char *file_system = file_path;
- file_name = file_system;
- int len = 0;
- while (true) {
- char c = *file_name;
- if (c == '/') {
- file_name++;
- break;
- }
- if (c == 0) {
- break;
- }
- len++;
- file_name++;
- }
- MBED_ASSERT(len != 0);
- fb = FileBase::lookup(file_system, len);
- }
- const char *FilePath::fileName(void)
- {
- return file_name;
- }
- bool FilePath::isFileSystem(void)
- {
- if (NULL == fb) {
- return false;
- }
- return (fb->getPathType() == FileSystemPathType);
- }
- FileSystemLike *FilePath::fileSystem(void)
- {
- if (isFileSystem()) {
- return static_cast<FileSystemLike *>(fb);
- }
- return NULL;
- }
- bool FilePath::isFile(void)
- {
- if (NULL == fb) {
- return false;
- }
- return (fb->getPathType() == FilePathType);
- }
- FileLike *FilePath::file(void)
- {
- if (isFile()) {
- return (FileLike *)fb;
- }
- return NULL;
- }
- bool FilePath::exists(void)
- {
- return fb != NULL;
- }
- }
|