/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter UniSharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

const Utils = require("./../../../unisharp/Utils");

// WindowsPathUtils provides simple utilities for handling windows paths.
class WindowsPathUtils {
    
    constructor() {
        
    }
    
    static dropPathRoot(path) {
        let result = path;
        if ((path !== null) && (path.length > 0)) {
            if ((path[0] === '\\') || (path[0] === '/')) {
                if ((path.length > 1) && (((path[1] === '\\') || (path[1] === '/')))) {
                    let index = 2;
                    let elements = 2;
                    while ((index <= path.length) && (((((path[index] !== '\\') && (path[index] !== '/'))) || ((--elements) > 0)))) {
                        index++;
                    }
                    index++;
                    if (index < path.length) 
                        result = path.substring(index);
                    else 
                        result = "";
                }
            }
            else if ((path.length > 1) && (path[1] === ':')) {
                let dropCount = 2;
                if ((path.length > 2) && (((path[2] === '\\') || (path[2] === '/')))) 
                    dropCount = 3;
                result = result.substring(dropCount);
            }
        }
        return result;
    }
}


module.exports = WindowsPathUtils