Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
Loading...
Searching...
No Matches
Macros | Functions
std_path.h File Reference

Standard library path resolution for Luma compiler. More...

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include <unistd.h>
Include dependency graph for std_path.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PATH_SEPARATOR   '/'
 
#define PATH_SEPARATOR_STR   "/"
 

Functions

bool resolve_std_path (const char *import_path, char *buffer, size_t buffer_size)
 Resolve a std/ import path to an actual file path.
 
bool get_system_std_path (char *buffer, size_t buffer_size)
 Get the system-wide Luma standard library path.
 
bool get_user_std_path (char *buffer, size_t buffer_size)
 Get the user-local Luma standard library path.
 
bool file_exists (const char *path)
 Check if a file exists at the given path.
 
const char * normalize_std_import (const char *path)
 Normalize a path by removing "std/" prefix if present.
 
void print_std_search_paths (void)
 

Detailed Description

Standard library path resolution for Luma compiler.

Resolves std/ imports by checking multiple locations:

  1. System-wide: /usr/local/lib/luma/std/ or C:\Program Files\luma\std\
  2. User-local: ~/.luma/std/ or USERPROFILE%.luma\std\
  3. Current directory: ./std/

Macro Definition Documentation

◆ PATH_SEPARATOR

#define PATH_SEPARATOR   '/'

◆ PATH_SEPARATOR_STR

#define PATH_SEPARATOR_STR   "/"

Function Documentation

◆ file_exists()

bool file_exists ( const char *  path)

Check if a file exists at the given path.

Parameters
pathPath to check
Returns
true if file exists, false otherwise

◆ get_system_std_path()

bool get_system_std_path ( char *  buffer,
size_t  buffer_size 
)

Get the system-wide Luma standard library path.

Parameters
bufferBuffer to store the path
buffer_sizeSize of the buffer
Returns
true if successful, false otherwise

◆ get_user_std_path()

bool get_user_std_path ( char *  buffer,
size_t  buffer_size 
)

Get the user-local Luma standard library path.

Parameters
bufferBuffer to store the path
buffer_sizeSize of the buffer
Returns
true if successful, false otherwise

◆ normalize_std_import()

const char * normalize_std_import ( const char *  path)

Normalize a path by removing "std/" prefix if present.

Parameters
pathThe input path
Returns
Pointer to the normalized path (within the input string)

◆ print_std_search_paths()

void print_std_search_paths ( void  )

◆ resolve_std_path()

bool resolve_std_path ( const char *  import_path,
char *  buffer,
size_t  buffer_size 
)

Resolve a std/ import path to an actual file path.

Parameters
import_pathThe import path (e.g., "std/io" or "std/math")
bufferBuffer to store the resolved path
buffer_sizeSize of the buffer
Returns
true if the path was resolved successfully, false otherwise