Code Monkey home page Code Monkey logo

os's Introduction

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

os's People

Contributors

jwerle avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.