Пример #1
0
  static Status
  dirEntryToStatus(const char * path, const DirEntry & dirEntry)
  {
    Pool pool;

    svn_wc_entry_t * e =
      static_cast<svn_wc_entry_t *>(
        apr_pcalloc(pool, sizeof(svn_wc_entry_t)));

    // path in in encoded form, but for our use it has to
    // be decoded
    std::string url(Url::unescape(path));
    url += "/";
    url += dirEntry.name();

    e->name = dirEntry.name();
    e->revision = dirEntry.createdRev();
    e->url = url.c_str();
    e->kind = dirEntry.kind();
    e->schedule = svn_wc_schedule_normal;
    e->text_time = dirEntry.time();
    e->prop_time = dirEntry.time();
    e->cmt_rev = dirEntry.createdRev();
    e->cmt_date = dirEntry.time();
    e->cmt_author = dirEntry.lastAuthor();

    bool locked = !isEmpty(dirEntry.lockToken());
    if (locked)
    {
      e->lock_token = dirEntry.lockToken();
      e->lock_owner = dirEntry.lockOwner();
      e->lock_comment = dirEntry.lockComment();
    }

    svn_wc_status2_t * s =
      static_cast<svn_wc_status2_t *>(
        apr_pcalloc(pool, sizeof(svn_wc_status2_t)));
    s->entry = e;
    s->text_status = svn_wc_status_normal;
    s->prop_status = svn_wc_status_normal;
    s->locked = 0;
    s->switched = 0;
    s->repos_text_status = svn_wc_status_normal;
    s->repos_prop_status = svn_wc_status_normal;

    return Status(url.c_str(), s);
  }
Пример #2
0
BlockDevice* VirtualFileSystem::openFile(const char* path) {
    DirEntry* root = getRoot();

    // we loop over each subfolder in the path
    while (true) {
        // first we skip as many slashes as we can
        while (*path == '/')
            path++;

        // then we get the length of the current folder, this is the length until the next / or the end
        int length = 0;
        while (path[length] != '/' && path[length] != '\0')
            length++;

        // if the length is zero, this was a trailing slash and we can stop here
        if (length == 0)
            break;

        // we get the folder name
        std::string cur(path, length);

        // and then try to find the directory that matches
        bool matched = false;
        while (root->valid()) {
            if (root->name() == cur) {
                // if we are at the end of the path, open the file as a stream
                if (path[length] == '\0') {
                    BlockDevice* file = root->openFile();
                    delete root;
                    return file;
                } else {
                    //otherwise, it's a directory on the way to the file
                    auto next = root->openDir();
                    delete root;
                    root = next;
                    matched = true;
                    break;
                }
                
            }
            root->advance();
        }

        if (!matched) {
            delete root;
            return nullptr;
        }

        path += length;
        if (*path == '\0')
            break;
    }

    return nullptr;
}
Пример #3
0
 void
 init(const DirEntry & src)
 {
   name = src.name();
   kind = src.kind();
   size = src.size();
   hasProps = src.hasProps();
   createdRev = src.createdRev();
   time = src.time();
   lastAuthor = src.lastAuthor();
   lockToken = src.lockToken();
   lockOwner = src.lockOwner();
   lockComment = src.lockComment();
 }