Shows how to process files stored in the virtual disk of Axional Studio (disktool) using the XSQL-Script file commands.

1 Access to disktool

Example
Copy
<xsql-script name='digest-disktool'>
    <body>

        <!-- Function example to the process of the line of a file -->
        <function name='local_digest'>
            <args>
                <arg name='p_file' />
            </args>
            <body>
                <!-- Generates a line reader on the file -->
                <set name='m_reader'>
                    <string.lineReader>
                        <p_file />
                    </string.lineReader>
                </set>

                <!-- For each line of the file, print the number of line and its content -->
                <while>
                    <expr>
                        <isnotnull>
                            <set name='p_line'>
                                <string.lineReader.readLine><m_reader/></string.lineReader.readLine>
                            </set>
                        </isnotnull>
                    </expr>
                    <do>
                        <println><string.lineReader.getLineNumber><m_reader/></string.lineReader.getLineNumber>:<p_line/></println>
                    </do>
                </while>
            </body>
        </function>

        <!-- Get an array with the file names of the disk of the folder called 'test 1' -->
        <set name='m_list'>
            <file.listFiles><file name='/test 1' type='disktool' /></file.listFiles>
        </set>

        <!-- For each file of the root directory, shows its properties -->
        <iterator name='m_file'>
            <in>
                <m_list />
            </in>
            <do>
                <if>
                    <expr>
                        <not><file.isDirectory><m_file/></file.isDirectory></not>
                    </expr>
                    <then>
                        <println>Processing file <file.getName><m_file/></file.getName></println>
                        <local_digest>
                            <m_file />
                        </local_digest>
                    </then>
                </if>
            </do>
        </iterator>
    </body>
</xsql-script>