UNPKG

node-red-contrib-fs-ops

Version:

A node-red node to perform basic file system operations.

1,219 lines (1,128 loc) 46.1 kB
<script type="text/javascript"> RED.nodes.registerType('fs-ops-move',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, sourcePath: {value: ""}, sourcePathType: {value: "str"}, sourceFilename: {value: "", required: true}, sourceFilenameType: {value: "msg"}, destPath: {value: "", required: true}, destPathType: {value: "str"}, destFilename: {value: "", required: true}, destFilenameType: {value: "msg"}, link: {value:false} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"File Move"; }, oneditprepare: function() { if (!this.sourcePathType) { this.sourcePathType = 'str'; } $("#node-input-sourcePath").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-sourcePathType") }); if (!this.sourceFilenameType) { this.sourceFilenameType = 'msg'; } $("#node-input-sourceFilename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-sourceFilenameType") }); if (!this.destPathType) { this.destPathType = 'str'; } $("#node-input-destPath").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-destPathType") }); if (!this.destFilenameType) { this.destFilenameType = 'msg'; } $("#node-input-destFilename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-destFilenameType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-move"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-sourcePath"><i class="fa fa-folder"></i> Source Path</label> <input type="text" id="node-input-sourcePath" placeholder="Path to move from" style="width:250px;"> <input type="hidden" id="node-input-sourcePathType"> </div> <div class="form-row"> <label for="node-input-sourceFilename"><i class="fa fa-file"></i> Source Filename</label> <input type="text" id="node-input-sourceFilename" placeholder="Old filename" style="width:250px;"> <input type="hidden" id="node-input-sourceFilenameType"> </div> <div class="form-row"> <label for="node-input-destPath"><i class="fa fa-folder"></i> Destination Path</label> <input type="text" id="node-input-destPath" placeholder="Path to move to" style="width:250px;"> <input type="hidden" id="node-input-destPathType"> </div> <div class="form-row"> <label for="node-input-destFilename"><i class="fa fa-file"></i> Destination Filename</label> <input type="text" id="node-input-destFilename" placeholder="New filename" style="width:250px;"> <input type="hidden" id="node-input-destFilenameType"> </div> <div class="form-row"> <label for="node-input-link"><i class="fa fa-link"></i> Link File</label> <input type="checkbox" value="false" id="node-input-link" style="display: inline-block; width: auto; vertical-align: top;"/> </div> </script> <script type="text/x-red" data-help-name="fs-ops-move"> <p>Move or rename a file in the local filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file to be moved</dd> <dt>source filename<span class="property-type">string</span></dt> <dd>Name of file to be moved</dd> <dt>destination path<span class="property-type">string</span></dt> <dd>Path of directory the file is to be moved to</dd> <dt>destination filename<span class="property-type">string</span></dt> <dd>New name to be used for file</dd> <dt>link file<span class="property-type">boolean</span></dt> <dd><i>Deprecated</i>: Link file in destination<dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>Input message is passed unchanged if no errors occur.</p> </dl> <h3>Details</h3> <p>Moves, renames or links a file from the source to the destination.</p> <p>Specified file is moved from the source path to the destination path and renamed from the source filename to the destination filename.</p> <p><b>Warning:</b>This node will always overwrite the destination.</p> <p>If <i>Link Files</i> is set, destination file will be a symbolic link to the source file. - DEPRECATED: Use File Copy node instead.</p> <p>Message is actioned and passed through unchanged if move/rename is successful.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-copy',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, sourcePath: {value: ""}, sourcePathType: {value: "str"}, sourceFilename: {value: "", required: true}, sourceFilenameType: {value: "msg"}, destPath: {value: "", required: true}, destPathType: {value: "str"}, destFilename: {value: "", required: true}, destFilenameType: {value: "msg"}, link: {value:false}, overwrite: {value: false} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"File Copy"; }, oneditprepare: function() { if (!this.sourcePathType) { this.sourcePathType = 'str'; } $("#node-input-sourcePath").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-sourcePathType") }); if (!this.sourceFilenameType) { this.sourceFilenameType = 'msg'; } $("#node-input-sourceFilename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-sourceFilenameType") }); if (!this.destPathType) { this.destPathType = 'str'; } $("#node-input-destPath").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-destPathType") }); if (!this.destFilenameType) { this.destFilenameType = 'msg'; } $("#node-input-destFilename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-destFilenameType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-copy"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-sourcePath"><i class="fa fa-folder"></i> Source Path</label> <input type="text" id="node-input-sourcePath" placeholder="Path to copy from" style="width:250px;"> <input type="hidden" id="node-input-sourcePathType"> </div> <div class="form-row"> <label for="node-input-sourceFilename"><i class="fa fa-file"></i> Source Filename</label> <input type="text" id="node-input-sourceFilename" placeholder="Source filename" style="width:250px;"> <input type="hidden" id="node-input-sourceFilenameType"> </div> <div class="form-row"> <label for="node-input-destPath"><i class="fa fa-folder"></i> Destination Path</label> <input type="text" id="node-input-destPath" placeholder="Path to copy to" style="width:250px;"> <input type="hidden" id="node-input-destPathType"> </div> <div class="form-row"> <label for="node-input-destFilename"><i class="fa fa-file"></i> Destination Filename</label> <input type="text" id="node-input-destFilename" placeholder="New filename" style="width:250px;"> <input type="hidden" id="node-input-destFilenameType"> </div> <div class="form-row"> <label for="node-input-link"><i class="fa fa-link"></i> Link</label> <input type="checkbox" value="false" id="node-input-link" style="display: inline-block; width: auto; vertical-align: top;"/> </div> <div class="form-row"> <label for="node-input-overwrite"><i class="fa fa-eraser"></i> Overwrite</label> <input type="checkbox" value="false" id="node-input-overwrite" style="display: inline-block; width: auto; vertical-align: top;"/> </div> </script> <script type="text/x-red" data-help-name="fs-ops-copy"> <p>Copies or links a file from the source to the destination.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file to be copied</dd> <dt>source filename<span class="property-type">string</span></dt> <dd>Name of file to be copied</dd> <dt>destination path<span class="property-type">string</span></dt> <dd>Path of directory the file is to be copied to</dd> <dt>destination filename<span class="property-type">string</span></dt> <dd>New name to be used for file</dd> <dt>link<span class="property-type">boolean</span></dt> <dd>Link file in destination<dd> <dt>overwrite<span class="property-type">boolean</span></dt> <dd>Overwrite existing destination file<dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>Input message is passed unchanged if no errors occur.</p> </dl> <h3>Details</h3> <p>Specified file is copied from the source path to the destination path and renamed from the source filename to the destination filename. An error is thrown if the destination file exists and the overwrite option is not set.</p> <p>If <i>Link Files</i> is set, destination file will be a symbolic link to the source file.</p> <p>Message is actioned and passed through unchanged if copy is successful.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-delete',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, filename: {value: "", required: true}, filenameType: {value: "msg"} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"File Delete"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.filenameType) { this.filenameType = 'msg'; } $("#node-input-filename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-filenameType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-delete"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path of file to delete" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-filename"><i class="fa fa-file"></i> Filename</label> <input type="text" id="node-input-filename" placeholder="File to delete" style="width:250px;"> <input type="hidden" id="node-input-filenameType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-delete"> <p>Deletes a file on host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file to be deleted</dd> <dt>source filename<span class="property-type">string|array of string</span></dt> <dd>Name/s of file/s to be deleted</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>Input message is passed unchanged if no errors occur.</p> </dl> <h3>Details</h3> <p>Deletes the specified files from the local filesystem. </p> <p>If an array of filenames is passed in, such as from the file-ops-dir node, then each file will be deleted.</p> <p>Message is actioned and passed through unchanged if no error is encountered.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-access',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, filename: {value: "", required: true}, filenameType: {value: "msg"}, read: {value: true}, write: {value: true}, throwerror: {value: false} }, inputs:1, outputs:2, icon: "file.png", label: function() { return this.name||"File Access"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.filenameType) { this.filenameType = 'msg'; } $("#node-input-filename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-filenameType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-access"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path of file to test" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-filename"><i class="fa fa-file"></i> Filename</label> <input type="text" id="node-input-filename" placeholder="File to test" style="width:250px;"> <input type="hidden" id="node-input-filenameType"> </div> <div class="form-row"> <label for="access"><i class="fa fa-lock"></i> Access</label> <input type="checkbox" checked value="true" id="node-input-read" style="display: inline-block; width: auto; vertical-align: top;"/> <label for="node-input-read" style="width: 30%;"> Read</label> <input type="checkbox" checked value="true" id="node-input-write" style="display: inline-block; width: auto; vertical-align: top;"/> <label for="node-input-write" style="width: 30%;"> Write</label> </div> <div class="form-row"> <label for="node-input-throwerror"><i class="fa fa-exclamation-triangle"></i> Throw Error</label> <input type="checkbox" checked value="true" id="node-input-throwerror" style="display: inline-block; width: auto; vertical-align: top;"/> </div> </script> <script type="text/x-red" data-help-name="fs-ops-access"> <p>Tests if a file is accessible on the host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file to be tested</dd> <dt>source filename<span class="property-type">string</span></dt> <dd>Name of file to be tested</dd> <dt>access</dt> <dd>Access modes to be tested</dd> <dt>throw error</dt> <dd>Throw error if access test fails</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>Input message is passed unchanged.</p> </dl> <h3>Details</h3> <p>Message is actioned and passed through output 1 unchanged if the file is accessible or output 2 with error if not accessible.</p> <p>Error is also optionally thrown which can trigger a Catch node.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-size',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, filename: {value: "", required: true}, filenameType: {value: "msg"}, size: {value: "filesize", required: true}, sizeType: {value: "msg"} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"File Size"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.filenameType) { this.filenameType = 'msg'; } $("#node-input-filename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-filenameType") }); if (!this.sizeType) { this.sizeType = 'msg'; } $("#node-input-size").typedInput({ default: 'msg', types: ['msg','flow','global'], typeField: $("#node-input-sizeType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-size"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-filename"><i class="fa fa-file"></i> Filename</label> <input type="text" id="node-input-filename" placeholder="Filename" style="width:250px;"> <input type="hidden" id="node-input-filenameType"> </div> <div class="form-row"> <label for="node-input-size"><i class="fa fa-edit"></i> Size Property</label> <input type="text" id="node-input-size" placeholder="Property to record size" style="width:250px;"> <input type="hidden" id="node-input-sizeType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-size"> <p>Determines the size of a file on host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file</dd> <dt>source filename<span class="property-type">string | array of string</span></dt> <dd>Name/s of file/s</dd> <dt>size property</dt> <dd>Property where file size is recorded</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>File size is stored in specified property.</p> </dl> <h3>Details</h3> <p>File size is added in the specified property. If passed an array of filenames, like from fs-ops-dir, node will add an array of corresponding file sizes.</p> <p>Error is thrown and message dropped if size cannot be determined.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-stats',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, filename: {value: "", required: true}, filenameType: {value: "msg"}, stats: {value: "stats", required: true}, sizeType: {value: "msg"} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"File Stats"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.filenameType) { this.filenameType = 'msg'; } $("#node-input-filename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-filenameType") }); if (!this.statsType) { this.statsType = 'msg'; } $("#node-input-stats").typedInput({ default: 'msg', types: ['msg','flow','global'], typeField: $("#node-input-statsType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-stats"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-filename"><i class="fa fa-file"></i> Filename</label> <input type="text" id="node-input-filename" placeholder="Filename" style="width:250px;"> <input type="hidden" id="node-input-filenameType"> </div> <div class="form-row"> <label for="node-input-stats"><i class="fa fa-edit"></i> Stats Property</label> <input type="text" id="node-input-stats" placeholder="Property to record size" style="width:250px;"> <input type="hidden" id="node-input-statsType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-stats"> <p>Returns the stats of a file on host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file</dd> <dt>source filename<span class="property-type">string | array of string</span></dt> <dd>Name/s of file/s</dd> <dt>size property</dt> <dd>Property where file size is recorded</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>File size is stored in specified property.</p> </dl> <h3>Details</h3> <p><a href="https://nodejs.org/docs/latest-v11.x/api/fs.html#fs_class_fs_stats">File stats object</a> is added in the specified property. If passed an array of filenames, like from fs-ops-dir, node will add an array of corresponding file stats.</p> <p>Error is thrown and message dropped if stats cannot be determined.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-link',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, filename: {value: "", required: true}, filenameType: {value: "msg"}, link: {value: "link", required: true}, linkType: {value: "msg"} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"Get Link"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.filenameType) { this.filenameType = 'msg'; } $("#node-input-filename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-filenameType") }); if (!this.linkType) { this.linkType = 'msg'; } $("#node-input-link").typedInput({ default: 'msg', types: ['msg','flow','global'], typeField: $("#node-input-linkType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-link"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-filename"><i class="fa fa-file"></i> Filename</label> <input type="text" id="node-input-filename" placeholder="Filename" style="width:250px;"> <input type="hidden" id="node-input-filenameType"> </div> <div class="form-row"> <label for="node-input-link"><i class="fa fa-edit"></i> Link Property</label> <input type="text" id="node-input-link" placeholder="Property to record link" style="width:250px;"> <input type="hidden" id="node-input-linkType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-link"> <p>Determines if a file on host filesystem is a link and returns the file it links to.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file</dd> <dt>source filename<span class="property-type">string | array of string</span></dt> <dd>Name/s of file/s</dd> <dt>link property</dt> <dd>Property where linked file is recorded</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>File link is stored in specified property.</p> </dl> <h3>Details</h3> <p>File linked is added in the specified property. If passed an array of filenames, like from fs-ops-dir, node will add an array of corresponding file links. If the file is not a link, the returned property will be an empty string.</p> <p>Error is thrown and message dropped if link cannot be determined.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-type',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, filename: {value: "", required: true}, filenameType: {value: "msg"}, filetype: {value: "type", required: true}, filetypeType: {value: "msg"} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"Get Type"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.filenameType) { this.filenameType = 'msg'; } $("#node-input-filename").typedInput({ default: 'msg', types: ['str','msg','flow','global'], typeField: $("#node-input-filenameType") }); if (!this.filetypeType) { this.filetypeType = 'msg'; } $("#node-input-type").typedInput({ default: 'msg', types: ['msg','flow','global'], typeField: $("#node-input-typeType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-type"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-filename"><i class="fa fa-file"></i> Filename</label> <input type="text" id="node-input-filename" placeholder="Filename" style="width:250px;"> <input type="hidden" id="node-input-filenameType"> </div> <div class="form-row"> <label for="node-input-filetype"><i class="fa fa-edit"></i> Type Property</label> <input type="text" id="node-input-filetype" placeholder="Property to record type" style="width:250px;"> <input type="hidden" id="node-input-filetypeType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-type"> <p>Determines the type of a file on host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory containing file</dd> <dt>source filename<span class="property-type">string | array of string</span></dt> <dd>Name/s of file/s</dd> <dt>type property</dt> <dd>Property where file type is recorded</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>File type is stored in specified property.</p> </dl> <h3>Details</h3> <p>File type is added in the specified property. If passed an array of filenames, like from fs-ops-dir, node will add an array of corresponding file types.</p> <p>Types are: <ul><li>F - Regular file</li> <li>D - Directory</li> <li>C - Character device</li> <li>B - Block device</li> <li>L - Symbolic link</li> <li>S - Special file</li> </ul></p> <p>Error is thrown and message dropped if type cannot be determined.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-dir',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, filter: {value: "*"}, filterType: {value: "str"}, dir: {value: "files", required: true}, dirType: {value: "msg"} }, inputs:1, outputs:1, icon: "db.png", label: function() { return this.name||"Directory"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.filterType) { this.filterType = 'msg'; } $("#node-input-filter").typedInput({ default: 'msg', types: ['str','msg','flow','global','env'], typeField: $("#node-input-filterType") }); if (!this.dirType) { this.dirType = 'msg'; } $("#node-input-dir").typedInput({ default: 'msg', types: ['msg','flow','global'], typeField: $("#node-input-dirType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-dir"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-filter"><i class="fa fa-filter"></i> Filter</label> <input type="text" id="node-input-filter" placeholder="Filename filter" style="width:250px;"> <input type="hidden" id="node-input-filterType"> </div> <div class="form-row"> <label for="node-input-dir"><i class="fa fa-edit"></i> Directory Property</label> <input type="text" id="node-input-dir" placeholder="Property to record directory files" style="width:250px;"> <input type="hidden" id="node-input-dirType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-dir"> <p>Lists the files in a directory on host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>source path<span class="property-type">string</span></dt> <dd>Path of directory</dd> <dt>filter<span class="property-type">string</span></dt> <dd>File name filter</dd> <dt>directory property</dt> <dd>Property where file names are recorded</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>File names stored in an array in the specified property.</p> </dl> <h3>Details</h3> <p>List of file names is stored in an array in the specified property. This array is suitable for passing to other fs-op nodes for further operations.</p> <p>Error is thrown and message dropped if directory cannot be accessed.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-mkdir',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, dirname: {value: "", required: true}, dirnameType: {value: "msg"}, recursive: {value: false, required: false}, mode: {value: "777", required: true, validate:RED.validators.regex(/[0-7][0-7][0-7]/)}, fullpath: {value: "directory"}, fullpathType: {value: "msg"} }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"Make Directory"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.dirnameType) { this.dirnameType = 'msg'; } $("#node-input-dirname").typedInput({ default: 'msg', types: ['str','msg','flow','global','env'], typeField: $("#node-input-dirnameType") }); if (!this.fullpathType) { this.fullpathType = 'msg'; } $("#node-input-fullpath").typedInput({ default: 'msg', types: ['msg','flow','global'], typeField: $("#node-input-fullpathType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-mkdir"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path of new directory" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-dirname"><i class="fa fa-folder"></i> Directory</label> <input type="text" id="node-input-dirname" placeholder="New directory name" style="width:250px;"> <input type="hidden" id="node-input-dirnameType"> </div> <div class="form-row"> <label for="node-input-recursive"></label> <input type="checkbox" id="node-input-recursive" style="display: inline-block; width: auto; vertical-align: top;"> <label for="node-input-recursive" style="width: auto"><i class="fa fa-sitemap"></i> Recursive</label> </div> <div class="form-row"> <label for="node-input-mode"><i class="icon-lock"></i> Access Mode</label> <input type="text" id="node-input-mode" placeholder="Octal"> </div> <div class="form-row"> <label for="node-input-fullpath"><i class="fa fa-edit"></i> Directory Property</label> <input type="text" id="node-input-fullpath" placeholder="Property to record directory name" style="width:250px;"> <input type="hidden" id="node-input-fullpathType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-mkdir"> <p>Makes a directory on host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>path<span class="property-type">string</span></dt> <dd>Path of directory containing new directory</dd> <dt>directory<span class="property-type">string</span></dt> <dd>Name of new directory</dd> <dt>access mode<span class="property-type">integer</span></dt> <dd>Access mode for new directory</dd> <dt>directory property</dt> <dd>Property where new directory path is recorded</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>New directory path is stored in specified property.</p> </dl> <h3>Details</h3> <p>Message is actioned and passed through if successful.</p> <p>Full pathname of new directory is added to the <i>Directory</i> property as specified.</p> </script> <script type="text/javascript"> RED.nodes.registerType('fs-ops-mktmpdir',{ category: 'storage', color: '#767432', defaults: { name: {value:""}, path: {value: ""}, pathType: {value: "str"}, prefix: {value: "", required: true}, prefixType: {value: "msg"}, mode: {value: "777", required: true, validate:RED.validators.regex(/[0-7][0-7][0-7]/)}, fullpath: {value: "directory", required: true}, fullpathType: {value: "msg"}, }, inputs:1, outputs:1, icon: "file.png", label: function() { return this.name||"Make Tmp Directory"; }, oneditprepare: function() { if (!this.pathType) { this.pathType = 'str'; } $("#node-input-path").typedInput({ default: 'str', types: ['str','msg','flow','global','env'], typeField: $("#node-input-pathType") }); if (!this.prefixType) { this.prefixType = 'msg'; } $("#node-input-prefix").typedInput({ default: 'msg', types: ['str','msg','flow','global','env'], typeField: $("#node-input-prefixType") }); if (!this.fullpathType) { this.fullpathType = 'msg'; } $("#node-input-fullpath").typedInput({ default: 'msg', types: ['msg','flow','global'], typeField: $("#node-input-fullpathType") }); } }); </script> <script type="text/x-red" data-template-name="fs-ops-mktmpdir"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-path"><i class="fa fa-folder"></i> Path</label> <input type="text" id="node-input-path" placeholder="Path of tmp directory" style="width:250px;"> <input type="hidden" id="node-input-pathType"> </div> <div class="form-row"> <label for="node-input-prefix"><i class="fa fa-folder"></i> Prefix</label> <input type="text" id="node-input-prefix" placeholder="New directory prefix" style="width:250px;"> <input type="hidden" id="node-input-prefixType"> </div> <div class="form-row"> <label for="node-input-fullpath"><i class="fa fa-edit"></i> Directory Property</label> <input type="text" id="node-input-fullpath" placeholder="Property to record directory name" style="width:250px;"> <input type="hidden" id="node-input-fullpathType"> </div> </script> <script type="text/x-red" data-help-name="fs-ops-mktmpdir"> <p>Creates a new temporary directory on host filesystem.</p> <h3>Properties</h3> <dl class="message-properties"> <dt>name <span class="property-type">string</span> </dt> <dd>Name of node to be displayed in editor</dd> <dt>path<span class="property-type">string</span></dt> <dd>Path of directory containing new directory</dd> <dt>prefix<span class="property-type">string</span></dt> <dd>Prefix of new directory name</dd> <dt>directory property</dt> <dd>Property where new directory path is recorded</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p>New directory path is stored in specified property.</p> </dl> <h3>Details</h3> <p>New directory name will be prefix with six random characters appended.</p> <p>Message is actioned and passed through if successful.</p> <p>Full pathname of new directory is added to the Directory property.</p> </script>