~ubuntu-branches/debian/experimental/libtorrent/experimental

« back to all changes in this revision

Viewing changes to src/data/entry_list.cc

  • Committer: Bazaar Package Importer
  • Author(s): Qingning Huo
  • Date: 2006-01-12 20:47:33 UTC
  • mto: (4.1.1 edgy) (6.2.1 squeeze) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060112204733-2vw5t3vdne40s8mq
Tags: upstream-0.8.2
ImportĀ upstreamĀ versionĀ 0.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
 
80
80
void
81
81
EntryList::open(const std::string& root) {
82
 
  make_directory(root);
83
82
  Path lastPath;
84
83
 
85
 
  for (iterator itr = begin(), last = end(); itr != last; ++itr) {
86
 
    if (itr->file_meta() != NULL)
87
 
      throw internal_error("EntryList::open(...) found an already opened file.");
88
 
      
89
 
    itr->set_file_meta(m_slotInsertFileMeta(root + itr->path()->as_string()));
90
 
      
91
 
    if (itr->path()->empty()) {
92
 
      close();
93
 
      throw storage_error("Found an empty filename.");
94
 
    }
95
 
 
96
 
    if (!open_file(root, &*itr, lastPath)) {
97
 
      close();
98
 
      throw storage_error("Could no open file \"" + root + itr->path()->as_string() + "\".");
99
 
    }
100
 
      
101
 
    lastPath = *itr->path();
 
84
  try {
 
85
    make_directory(root);
 
86
 
 
87
    for (iterator itr = begin(), last = end(); itr != last; ++itr) {
 
88
      if (itr->file_meta() != NULL)
 
89
        throw internal_error("EntryList::open(...) found an already opened file.");
 
90
      
 
91
      itr->set_file_meta(m_slotInsertFileMeta(root + itr->path()->as_string()));
 
92
      
 
93
      if (itr->path()->empty())
 
94
        throw storage_error("Found an empty filename.");
 
95
 
 
96
      if (!open_file(root, &*itr, lastPath))
 
97
        throw storage_error("Could no open file \"" + root + itr->path()->as_string() + "\".");
 
98
      
 
99
      lastPath = *itr->path();
 
100
    }
 
101
 
 
102
  } catch (storage_error& e) {
 
103
    close();
 
104
    throw e;
102
105
  }
103
106
}
104
107
 
140
143
EntryList::open_file(const std::string& root, EntryListNode* node, const Path& lastPath) {
141
144
  make_directory(root, node->path()->begin(), --node->path()->end(), lastPath.begin(), lastPath.end());
142
145
 
 
146
  // Some torrents indicate an empty directory by having a path with
 
147
  // an empty last element. This entry must be zero length.
143
148
  if (node->path()->back().empty())
144
149
    return node->size() == 0;
145
150