Path Utilities (পাথ ইউটিলিটি)
BanglaCode provides comprehensive cross-platform path manipulation utilities. All operations are OS-aware and handle Windows, Linux, and macOS path conventions automatically.
Path Constants
PATH_SEP & PATH_DELIMITER
Platform-specific path separator and delimiter constants.
dhoro sep = PATH_SEP; // Unix: "/" | Windows: "\\"
dhoro delim = PATH_DELIMITER; // Unix: ":" | Windows: ";"Path Functions
path_resolve(...paths)
Resolves paths to absolute path.
dhoro abs = path_resolve(".", "src", "main.bang");
dekho(abs); // /home/user/project/src/main.bangpath_normalize(path)
Normalizes path by removing redundant separators and resolving . and ..
dhoro clean = path_normalize("/foo//bar/../baz");
dekho(clean); // /foo/bazpath_relative(base, target)
Computes relative path from base to target.
dhoro rel = path_relative("/home/user", "/home/user/docs/file.txt");
dekho(rel); // docs/file.txtpath_joro(...segments)
Joins path segments using platform-specific separator.
dhoro fullPath = path_joro("home", "user", "file.txt");
// Unix: home/user/file.txt | Windows: home\user\file.txtdirectory_naam(path)
Returns directory name of a path.
dhoro dir = directory_naam("/home/user/file.txt");
dekho(dir); // /home/userpath_naam(path)
Returns base name (filename or directory name).
dhoro name = path_naam("/home/user/document.txt");
dekho(name); // document.txtfile_ext(path)
Returns file extension (including dot).
dhoro ext = file_ext("program.bang");
dekho(ext); // .bangReal-World Example
Path Analysis Utility
kaj analyzePath(filePath) {
ferao {
absolute: path_resolve(filePath),
normalized: path_normalize(filePath),
directory: directory_naam(filePath),
filename: path_naam(filePath),
extension: file_ext(filePath),
separator: PATH_SEP
};
}
dhoro result = analyzePath("./src/../lib/utils.bang");
dekho(result);
// {
// absolute: "/home/user/project/lib/utils.bang",
// normalized: "lib/utils.bang",
// directory: ".",
// filename: "utils.bang",
// extension: ".bang",
// separator: "/"
// }API Summary
| Function/Constant | Description |
|---|---|
PATH_SEP | Platform path separator |
PATH_DELIMITER | Platform path list delimiter |
path_resolve(...paths) | Resolve to absolute path |
path_normalize(path) | Normalize path |
path_relative(base, target) | Get relative path |
path_joro(...segments) | Join path segments |
directory_naam(path) | Get directory name |
path_naam(path) | Get base name |
file_ext(path) | Get file extension |