Skip to content

Commit

Permalink
Implement fs.readLink to read symlink target.
Browse files Browse the repository at this point in the history
  • Loading branch information
ariya committed Mar 17, 2012
1 parent c2c80c0 commit c6091b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ QVariant FileSystem::lastModified(const QString &path) const
return QVariant(QDateTime());
}

// Links
QString FileSystem::readLink(const QString &path) const
{
return QFileInfo(path).symLinkTarget();
}

// Tests
bool FileSystem::exists(const QString &path) const
{
Expand Down Expand Up @@ -446,6 +452,7 @@ void FileSystem::initCompletions()
// functions
addCompletion("list");
addCompletion("absolute");
addCompletion("readLink");
addCompletion("exists");
addCompletion("isDirectory");
addCompletion("isFile");
Expand Down
3 changes: 3 additions & 0 deletions src/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public slots:
bool changeWorkingDirectory(const QString &path) const;
QString absolute(const QString &relativePath) const;

// Links
QString readLink(const QString &path) const;

// Tests
bool exists(const QString &path) const;
bool isDirectory(const QString &path) const;
Expand Down
7 changes: 6 additions & 1 deletion test/fs-spec-03.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ describe("Files and Directories API", function() {
fs.removeTree(TEST_DIR);
expect(fs.changeWorkingDirectory(START_CWD)).toBeTruthy();
});
});

// TODO: test the actual functionality once we can create symlink.
it("should have readLink function", function() {
expect(typeof fs.readLink).toEqual('function');
});
});

0 comments on commit c6091b4

Please sign in to comment.