UNPKG

1.11 kBJavaScriptView Raw
1'use strict';
2
3var path = require('path');
4var util = require('util');
5
6var Item = require('./item');
7
8var constants = process.binding('constants');
9
10
11
12/**
13 * A directory.
14 * @constructor
15 */
16function SymbolicLink() {
17 Item.call(this);
18
19 /**
20 * Relative path to source.
21 * @type {string}
22 */
23 this._path = undefined;
24
25}
26util.inherits(SymbolicLink, Item);
27
28
29/**
30 * Set the path to the source.
31 * @param {string} pathname Path to source.
32 */
33SymbolicLink.prototype.setPath = function(pathname) {
34 this._path = pathname;
35};
36
37
38/**
39 * Get the path to the source.
40 * @return {string} Path to source.
41 */
42SymbolicLink.prototype.getPath = function() {
43 return this._path;
44};
45
46
47/**
48 * Get symbolic link stats.
49 * @return {Object} Stats properties.
50 */
51SymbolicLink.prototype.getStats = function() {
52 var size = this._path.length;
53 var stats = Item.prototype.getStats.call(this);
54 stats.mode = this.getMode() | constants.S_IFLNK;
55 stats.size = size;
56 stats.blocks = Math.ceil(size / 512);
57 return stats;
58};
59
60
61/**
62 * Export the constructor.
63 * @type {function()}
64 */
65exports = module.exports = SymbolicLink;