Bnlang File Paths

Working with file paths is an important part of file system operations in Bnlang.
File paths can be absolute (starting from the root of the file system) or relative (starting from the current working directory).
Bnlang provides built-in modules to handle file paths in a cross-platform way, so your programs work on Windows, Linux, and macOS.


Types of Paths

  • Absolute Path → Specifies the full path from the root of the file system.
  • Relative Path → Specifies the path relative to the current working directory.
  • Cross-Platform Paths → Use helpers to handle different separators (e.g., / in Linux, \ in Windows).

Example: Using File Paths

const path = require("path");

// অ্যাবসোলিউট পাথ
const পূর্ণপাথ = path.resolve("/user/docs/file.txt");
কনসোল.লগ("পূর্ণ:", পূর্ণপাথ);

// রিলেটিভ পাথ
const আপেক্ষিক = path.join("docs", "file.txt");
কনসোল.লগ("আপেক্ষিক:", আপেক্ষিক);

Best Practices

  • Always use the path module for portability.
  • Avoid hardcoding separators (/ or \) in your code.
  • Use path.resolve() for absolute paths and path.join() for building relative paths.
  • Test file operations on multiple platforms if your project targets cross-platform environments.