UNPKG

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