Proper '/' on the end of directories in the find-file window.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@381 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-04-03 16:36:19 +00:00
parent fe11d1936d
commit 874e46fc64
15 changed files with 216 additions and 24 deletions
+2
View File
@@ -3,6 +3,8 @@ noinst_LIBRARIES = libsub_utils.a
libsub_utils_a_SOURCES = \
directory.cc \
directory.h \
file_stat.cc \
file_stat.h \
list_focus.h \
parse.cc \
parse.h \
+70
View File
@@ -0,0 +1,70 @@
// rTorrent - BitTorrent client
// Copyright (C) 2005, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#include "config.h"
#include <stdexcept>
#include "file_stat.h"
namespace utils {
void
FileStat::update_throws(int fd) {
int r = update(fd);
if (r < 0)
throw std::runtime_error(error_string(r));
}
void
FileStat::update_throws(const char* filename) {
int r = update(filename);
if (r < 0)
throw std::runtime_error(error_string(r));
}
std::string
FileStat::error_string(int err) {
switch (err) {
case 0:
return "Success";
case EBADF:
return "Bad file descriptor";
case ENOENT:
return "Filename does not exist";
case ENOTDIR:
return "Path not a directory";
case EACCES:
return "Permission denied";
default:
return "Unknown error";
}
}
}
+66
View File
@@ -0,0 +1,66 @@
// libTorrent - BitTorrent library
// Copyright (C) 2005, Jari Sundell
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Contact: Jari Sundell <jaris@ifi.uio.no>
//
// Skomakerveien 33
// 3185 Skoppum, NORWAY
#ifndef RTORRENT_UTILS_FILE_STAT_H
#define RTORRENT_UTILS_FILE_STAT_H
#include <string>
#include <inttypes.h>
#include <sys/stat.h>
namespace utils {
class FileStat {
public:
FileStat() {}
FileStat(const char* filename) { update_throws(filename); }
explicit FileStat(int fd) { update_throws(fd); }
int update(int fd) { return fstat(fd, &m_stat); }
int update(const char* filename) { return stat(filename, &m_stat); }
void update_throws(int fd);
void update_throws(const char* filename);
bool is_regular() const { return S_ISREG(m_stat.st_mode); }
bool is_directory() const { return S_ISDIR(m_stat.st_mode); }
bool is_character() const { return S_ISCHR(m_stat.st_mode); }
bool is_block() const { return S_ISBLK(m_stat.st_mode); }
bool is_fifo() const { return S_ISFIFO(m_stat.st_mode); }
bool is_link() const { return S_ISLNK(m_stat.st_mode); }
bool is_sockt() const { return S_ISSOCK(m_stat.st_mode); }
off_t get_size() const { return m_stat.st_size; }
time_t get_atime() const { return m_stat.st_atime; }
time_t get_ctime() const { return m_stat.st_ctime; }
time_t get_mtime() const { return m_stat.st_mtime; }
static std::string error_string(int err);
private:
struct stat m_stat;
};
}
#endif