Skip to content

zzmodules/os

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

os

Operating system abstractions for ZZ

Installation

Add this to your zz.toml file:

[dependencies]
os = "*"

[repos]
os = "git://github.com/zzmodules/os"

Usage

using os

API

os::arch() -> Arch

Returns the detected architecture for the operating system.

if os::arch() == os::arch::arm { }
else if os::arch() == os::arch::arm64 { }
else if os::arch() == os::arch::ia32 { }
else if os::arch() == os::arch::mips { }
else if os::arch() == os::arch::ppc { }
else if os::arch() == os::arch::ppc64 { }
else if os::arch() == os::arch::x32 { }
else if os::arch() == os::arch::x64 { }
else { err::panic("unknown architecture"); }

os::eol() -> char *

Returns the detected operating system specific "end-of-line" marker.

let eol = os::eol();

os::type() -> Type

Returns the detected operating system type.

if os::type() == os::type::apple { }
else if os::type() == os::type::linux { }
else if os::type() == os::type::posix { }
else if os::type() == os::type::unix { }
else if os::type() == os::type::windows { }
else { err::panic("unknown operating system"); }

os::detect

The following preprocessor values are available for operating system and architecture detection in macro conditional statements:

  • os::detect::amd
  • os::detect::amd64
  • os::detect::apple
  • os::detect::arm
  • os::detect::arm64
  • os::detect::i386
  • os::detect::linux
  • os::detect::mips
  • os::detect::posix
  • os::detect::ppc
  • os::detect::ppc64
  • os::detect::unix
  • os::detect::windows
fn platform_specific() -> int
  if #(os::detect::apple) {
    return 1;
  } else if #(os::detect::linux) {
    return 2;
  } else if #(os::detect::unix) {
    return 3;
  } else if #(os::detect::posix) {
    return 4;
  } else if #(os::detect::windows) {
    return 5;
  } else {
    // unknown operating system
    return 0;
  }

License

MIT

About

Operating system abstractions for ZZ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published