onepub-dev / dart_posix

MIT License
13 stars 5 forks source link

How to set get permissions from a file and set new permissions? #14

Open stephane-archer opened 4 days ago

stephane-archer commented 4 days ago

I didn't find the right way to do this

bsutton commented 4 days ago

Look at chmod and chown.

Read up on Linux permissions.

On Thu, Nov 14, 2024, 3:55 AM Stéphane Archer @.***> wrote:

I didn't find the right way to do this

— Reply to this email directly, view it on GitHub https://github.com/onepub-dev/dart_posix/issues/14, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OD5PAYST5SAFZODSXL2AN76LAVCNFSM6AAAAABRW6M6JCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGY2TMMJVGI4DKMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

stephane-archer commented 3 days ago

I was able to make it work, thank you for your help:

    var inputMode = inputFile.statSync().mode;
    String permissions = FileOperations.modeOctalString(inputMode);
    chmod(outputFile.path, permissions);

you might want to add a chmod version that takes a mode rather than an octal string to make it easier to use with the standard library

stephane-archer commented 3 days ago

https://github.com/onepub-dev/dart_posix/pull/15