1 /** 2 * --------- 3 * |.##> <##.| Open Smart Card Development Platform (www.openscdp.org) 4 * |# #| 5 * |# #| Copyright (c) 1999-2018 CardContact Software & System Consulting 6 * |'##> <##'| Andreas Schwier, 32429 Minden, Germany (www.cardcontact.de) 7 * --------- 8 * 9 * This file is part of OpenSCDP. 10 * 11 * OpenSCDP is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License version 2 as 13 * published by the Free Software Foundation. 14 * 15 * OpenSCDP is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with OpenSCDP; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 * 24 * @fileoverview Implementation of a ISO 7816-4 file system simulation 25 */ 26 27 28 29 /** 30 * Construct a file system node 31 * 32 * @class Abstract class for file system nodes 33 * @constructor 34 */ 35 function FSNode(fcp) { 36 this.parent = null; 37 this.fcp = fcp; 38 } 39 40 exports.FSNode = FSNode; 41 42 43 44 /** 45 * Sets the parent for this node 46 * 47 * @param {DF} the parent node 48 */ 49 FSNode.prototype.setParent = function(parent) { 50 if ((typeof(parent) != "object") && !(parent.isDF())) { 51 throw new GPError("FSNode", GPError.INVALID_TYPE, 0, "Argument parent must be of type DF"); 52 } 53 this.parent = parent; 54 } 55 56 57 58 /** 59 * Gets the parent node for this node 60 * 61 * @type DF 62 * @returns the parent node 63 */ 64 FSNode.prototype.getParent = function() { 65 return this.parent; 66 } 67 68 69 70 /** 71 * Gets the file control parameter for this node 72 * 73 * @type FCP 74 * @returns the FCP 75 */ 76 FSNode.prototype.getFCP = function() { 77 return this.fcp; 78 } 79 80 81 82 /** 83 * Returns true if this is a DF 84 * 85 * @type boolean 86 * @return true if this is a DF 87 */ 88 FSNode.prototype.isDF = function() { 89 return false; 90 } 91 92 93 94 /** 95 * Returns a human readible string 96 * 97 * @type String 98 * @return a string 99 */ 100 FSNode.prototype.toString = function() { 101 if (!this.fcp || !this.fcp.getFID()) { 102 return "FSNode"; 103 } 104 return this.fcp.getFID().toString(HEX); 105 } 106 107