|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 2009-2010 Obliter0n
|
|
Packit |
5e46da |
* Copyright (C) 2009-2010 John Stebbins
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is free software; you can redistribute it and/or
|
|
Packit |
5e46da |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License as published by the Free Software Foundation; either
|
|
Packit |
5e46da |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
5e46da |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5e46da |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
5e46da |
* Lesser General Public License for more details.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License along with this library. If not, see
|
|
Packit |
5e46da |
* <http://www.gnu.org/licenses/>.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#ifndef FILE_H_
|
|
Packit |
5e46da |
#define FILE_H_
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include "filesystem.h"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include "util/attributes.h"
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#include <stdint.h>
|
|
Packit |
5e46da |
#include <stddef.h>
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#ifdef _WIN32
|
|
Packit |
5e46da |
# define DIR_SEP "\\"
|
|
Packit |
5e46da |
# define DIR_SEP_CHAR '\\'
|
|
Packit |
5e46da |
#else
|
|
Packit |
5e46da |
# define DIR_SEP "/"
|
|
Packit |
5e46da |
# define DIR_SEP_CHAR '/'
|
|
Packit |
5e46da |
#endif
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* file access
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
//#define file_eof(X) X->eof(X)
|
|
Packit |
5e46da |
//#define file_write(X,Y,Z) (size_t)X->write(X,Y,Z)
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static inline void file_close(BD_FILE_H *fp)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
fp->close(fp);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static inline int64_t file_tell(BD_FILE_H *fp)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
return fp->tell(fp);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static inline BD_USED int64_t file_seek(BD_FILE_H *fp, int64_t offset, int32_t origin)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
return fp->seek(fp, offset, origin);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
static inline BD_USED size_t file_read(BD_FILE_H *fp, uint8_t *buf, size_t size)
|
|
Packit |
5e46da |
{
|
|
Packit |
5e46da |
return (size_t)fp->read(fp, buf, (int64_t)size);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE int64_t file_size(BD_FILE_H *fp);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE extern BD_FILE_H* (*file_open)(const char* filename, const char *mode);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE BD_FILE_OPEN file_open_default(void);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* directory access
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#define dir_close(X) X->close(X)
|
|
Packit |
5e46da |
#define dir_read(X,Y) X->read(X,Y)
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE extern BD_DIR_H* (*dir_open)(const char* dirname);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE BD_DIR_OPEN dir_open_default(void);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* local filesystem
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
BD_PRIVATE int file_unlink(const char *file);
|
|
Packit |
5e46da |
BD_PRIVATE int file_path_exists(const char *path);
|
|
Packit |
5e46da |
BD_PRIVATE int file_mkdir(const char *dir);
|
|
Packit |
5e46da |
BD_PRIVATE int file_mkdirs(const char *path);
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
#endif /* FILE_H_ */
|