Giter Site home page Giter Site logo

io-path-mode's Introduction

IO::Path::Mode

Augment Raku's IO::Path with a .mode() method to get the file mode

Build Status

Synopsis

use IO::Path::Mode;

my $mode = "some-file".IO.mode;

say $mode.set-user-id ?? 'setuid' !! 'not setuid';

say $mode.user.execute ?? 'executable' !! 'not executable';

say $mode.file-type == IO::Path::Mode::File ?? 'file' !! 'something other than a normal file';

...

Description

This augments the type IO::Path to provide a .mode method that allows you to get at the file permissions (or mode.) It follows the POSIX model pf user, group and other permissions and consequently may not make a meaningful result on e.g. Windows (although the underlying calls appear to return something approximating the correct answer.)

If you have a more recent rakudo that provides a mode method, it will replace that method with one that returns an IO::Path::Mode object rather than an IntStr, this is a transitional arrangement and will be deprecated in a future release in favour of a different method name.

It relies on some non-specified functionality in the VM so may probably only work with Rakudo on MoarVM.

This is mostly provided as some relief for not having the functionality directly exposed in Rakudo and as a discussion board for the best way of implementing the functionality going forward.

Installation

Assuming you have a working Rakudo installation you should be able to install this with zef :

# From the source directory

zef install .

# Remote installation

zef install IO::Path::Mode

Support

I welcome suggestions, patches and bug reports at https://github.com/jonathanstowe/IO-Path-Mode/issues

I'd be particularly interested in suggestions relating to making the mode mutable and adding a multi candidate for 'chmod' that can take an IO::Path::Mode object.

Licence

This is free software.

Please see the LICENCE file in the distribution

© Jonathan Stowe 2016 - 2021

io-path-mode's People

Contributors

0racle avatar jonathanstowe avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

samcv

io-path-mode's Issues

Make our mode more like the real IO::Path.mode

When mode was added to IO::Path a while back, parts of this module were adjusted to deal with this but both Int and ``gist``` return the representation of the full mode returned by stat rather than just the permission bits as the real mode does.

So I am proposing that in the interests of least surprise to the user (who may only have got this mode by it being added in some other code,) that both Int and gist should only be the permissions bits.

The may require some additional ACCEPTS candidates but we'll see.

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.