Git Product home page Git Product logo

sys-filesystem's Introduction

Ruby

Description

A cross platform Ruby interface for getting file system information.

Installation

gem install sys-filesystem

Adding the trusted cert

gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-filesystem/main/certs/djberg96_pub.pem)

Synopsis

require 'sys/filesystem'
include Sys
   
# Display information about a particular filesystem.
p Filesystem.stat('/')

# Sample output

#<Sys::Filesystem::Stat:0x517440
  @base_type = "ufs",
  @flags = 4,
  @files_available = 3817457,
  @block_size = 8192,
  @blocks_available = 19957633,
  @blocks = 34349612,
  @name_max = 255,
  @path = "/",
  @filesystem_id = 35651592,
  @files = 4135040,
  @fragment_size = 1024,
  @files_free = 3817457,
  @blocks_free = 20301129
>
   
# Describe all mount points on the system
Filesystem.mounts{ |mount| p mount }
   
# Find the mount point of any particular file
puts Filesystem.mount_point('/home/djberge/some_file.txt') => '/home'

Notes

This is a pure Ruby implementation that uses FFI. This means it should work with JRuby, too.

Sample code

Run 'rake example' if you want to see a basic sample run. The actual code is 'example_stat.rb' in the 'examples' directory. Modify it as you see fit.

Known Bugs

None that I'm aware of. Please report bugs on the project page at:

https://github.com/djberg96/sys-filesystem

Future Plans

  • Add better 64-bit support for Linux and BSD.
  • Other suggestions welcome.

Acknowledgements

  • Mike Hall, for ideas and code that I borrowed from his 'filesystem' library.
  • Park Heesob, for implementation and API ideas for the MS Windows version.
  • Nobuyoshi Miyokawa, for adding the original FreeBSD and OS X support.

License

Apache-2.0

Copyright

(C) 2003-2020 Daniel J. Berger All Rights Reserved

Warranty

This library is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.

Author

Daniel J. Berger

sys-filesystem's People

Contributors

alexeikh avatar djberg96 avatar filipovici-andrei avatar gogainda avatar hirura avatar map7 avatar nicklamuro avatar pravi avatar slewsys 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.