Lucene 源码分析集------- FileUtils

封装了一些文件操作的接口,使用的是boost库里面的文件操作,封装的好处是以后即使不用boost库也不至于影响使用者。

namespace FileUtils {

/// Return true if given file or directory exists.
LPPAPI bool fileExists(const String& path);

/// Return file last modified date and time.
LPPAPI uint64_t fileModified(const String& path);

/// Set file last modified date and time to now.
LPPAPI bool touchFile(const String& path);

/// Return file length in bytes.
LPPAPI int64_t fileLength(const String& path);

/// Set new file length, truncating or expanding as required.
LPPAPI bool setFileLength(const String& path, int64_t length);

/// Delete file from file system.
LPPAPI bool removeFile(const String& path);

/// Copy a file to/from file system.
LPPAPI bool copyFile(const String& source, const String& dest);

/// Create new directory under given location.
LPPAPI bool createDirectory(const String& path);

/// Delete directory from file system.
LPPAPI bool removeDirectory(const String& path);

/// Return true if given path points to a directory.
LPPAPI bool isDirectory(const String& path);

/// Return list of files (and/or directories) under given directory.
/// @param path path to list directory.
/// @param filesOnly if true the exclude sub-directories.
/// @param dirList list of files to return.
LPPAPI bool listDirectory(const String& path, bool filesOnly, HashSet<String> dirList);

/// Copy a directory to/from file system.
LPPAPI bool copyDirectory(const String& source, const String& dest);

/// Return complete path after joining given directory and file name.
LPPAPI String joinPath(const String& path, const String& file);

/// Extract parent path from given path.
LPPAPI String extractPath(const String& path);

/// Extract file name from given path.
LPPAPI String extractFile(const String& path);
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值