genode/libports/src/server/ffat_fs/node.h
Christian Prochaska 97308f963a ffat_fs: work with absolute paths
The recently added 'Genode::Path' class makes it easy to create absolute
paths. With this patch the 'ffat_fs' server uses the 'Genode::Path' class
where possible instead of working with 'f_chdir()' and relative paths.
This also solves the problem reported in issue #355, which was caused by
storing a relative file name in the 'File' node.

Fixes #355.
2012-09-14 12:23:26 +02:00

56 lines
974 B
C++

/*
* \brief FFAT file-system node
* \author Christian Prochaska
* \date 2012-07-04
*/
#ifndef _NODE_H_
#define _NODE_H_
/* Genode includes */
#include <os/path.h>
/* ffat includes */
namespace Ffat { extern "C" {
#include <ffat/ff.h>
} }
namespace File_system {
typedef Genode::Path<_MAX_LFN + 1> Absolute_path;
class Node
{
protected:
Absolute_path _name;
public:
Node(const char *name) : _name(name) { }
char const *name() { return _name.base(); }
/*
* A generic Node object can be created to represent a file or
* directory by its name without opening it, so the functions
* of this class must not be abstract.
*/
virtual size_t read(char *dst, size_t len, seek_off_t)
{
PERR("read() called on generic Node object");
return 0;
}
virtual size_t write(char const *src, size_t len, seek_off_t)
{
PERR("write() called on generic Node object");
return 0;
}
};
}
#endif /* _NODE_H_ */