blob: cbdeff46cc7a0ddf0c425322ee409b265038ab42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
$NetBSD: patch-ad,v 1.2 2008/12/16 16:49:52 tron Exp $
--- src/utils/directory.cc.orig 2008-05-07 13:19:11.000000000 +0100
+++ src/utils/directory.cc 2008-12-16 16:45:58.000000000 +0000
@@ -38,6 +38,7 @@
#include <algorithm>
#include <functional>
+#include <sys/stat.h>
#include <dirent.h>
#include <rak/path.h>
#include <torrent/exceptions.h>
@@ -63,7 +64,9 @@
if (m_path.empty())
throw torrent::input_error("Directory::update() tried to open an empty path.");
- DIR* d = opendir(rak::path_expand(m_path).c_str());
+ std::string path=rak::path_expand(m_path);
+
+ DIR* d = opendir(path.c_str());
if (d == NULL)
return false;
@@ -73,12 +76,18 @@
while ((entry = readdir(d)) != NULL) {
if ((flags & update_hide_dot) && entry->d_name[0] == '.')
continue;
+
+ std::string full_path = path + '/';
+ full_path += entry->d_name;
+
+ struct stat sb;
+ if (stat(full_path.c_str(), &sb))
+ continue;
iterator itr = base_type::insert(end(), value_type());
- itr->d_fileno = entry->d_fileno;
- itr->d_reclen = entry->d_reclen;
- itr->d_type = entry->d_type;
+ itr->d_fileno = sb.st_ino;
+ itr->d_type = sb.st_mode;
#ifdef DIRENT_NAMLEN_EXISTS_FOOBAR
itr->d_name = std::string(entry->d_name, entry->d_name + entry->d_namlen);
|