pub repository
mirror.p-hatan.composix
2.1.1Exposes the POSIX api on OSx and Linux
Readme
Provides Dart access to the POSIX api for osx and linux system.
import 'package:posix/posix.dart';
int uid = getuid();
Contributing
Dart types only
The api should only expose dart types. Any C types MUST be translated to dart types before being returned.
setters and getters
One of the first questsion is to whether we should use Dart's settings and getters:
e.g.
// getuid
int uid = getuid;
or
int uid = getuid();
/// setuid
uid = myuid;
or
setuid = uid;
or
setuid(uid);
My initial thoughts is to make the api identical to the posix api which would mean that we don't use Dart setters and getters.
error returns
Do we return error no.s or do we throw.
As Dart is a modern language it uses Exception whereas posix returns erorr codes.
Often posix will return null and then expect you to make a separate call to 'errorno' to get the actually error no.
I'm inclined to bring the api that we expose into the modern world.
So I'm proposing that if an posix api returns an error that we throw a PosixException with a message and error code.
Adding additional functions
The process of adding additional functions is:
- Install ffigen
dart pub global activate ffigen
- Run the ffigen setup.
The paths may be different on your system. Search for clang-c/Index.h
sudo apt-get install libclang-dev
dart pub run ffigen:setup -I/usr/lib/llvm-11/include -L/usr/lib/llvm-11/lib
-
find the required posix header file
-
use ffigen to create the initial dart file from the header.
- add your header file to ffigen.yaml
-
Run ffigen
dart pub run ffigen --config ffigen.yaml
- convert each method to take/return dart types.
Changelog
2.1.1
Added simplified library with method getUserNameByUid
2.1.0
Added stat function.
2.0.0
First stable nnbd release.
2.0.0-nullsafety.1
removed dcli as a dependency to avoid circular dependecies. First nullsafety release.
1.3.4
reverted Opaque to Struct as not supported under 2.10.
1.3.3
Updated empty structs to use Opaque
1.3.2
improved getlogin errors. Fixed bugs where we were comparing c null to the dart null which is not the same thing.
1.3.1
Added method to check if posix is supported.
1.3.0
Fixed chmod. Now throws an exception if an error is returned rather then returning -1;
1.2.0
Added grp.h to allow access to posix groups.
1.1.0
Added passwd methods to library. Applied consistent naming convention to entry points that expose native types.
1.0.0
testing for setuid/setgid Added dart wrappers for a number of posix methods so users don't need to play with ffi internals. Fixed bug where the ctor args where not setting the fields. re-organised method location. changed path to lookup function. Cleaned up types. Corrected type for method. Added test for getcwd.
0.4.1
Converted most of the unistd.dart methods to dart types. Now need to see If we can actually call any of the methods. generated code for strings.h no conversions as yet.
0.4.0
Work on changing all types sent and returned from the api to dart types. Also changed the methods to all be global functions.
Still a chunk more work to do to complete the conversion of all data types. Next step will be to create some unit test to prove the basic process is working.
0.3.0
Some very early work on bindings to unistd.h. Started by generating bindings using ffigen and then begun cleanup with the intent that all passed/returned types are native Dart types.
0.2.0
generated code using ffigen.
0.1.0
Initial commit
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add posixpubspec.yaml
name: posix
version: 2.1.1
homepage: https://github.com/bsutton/dart_posix
description: Exposes the POSIX api on OSx and Linux
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
ffi: ^1.0.0
dev_dependencies:
dcli: ^1.0.0
pedantic: ^1.10.0
test: ^1.16.2
ffigen: ^2.0.0
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | 2020-09-19T23:05:37.303879Z | Download | 734df62a1b6909438f2ef3e3315cdb34e58878cd77c64ff3c15740dd52a1ae39 |
| 0.2.0 | 2020-09-20T09:20:15.962003Z | Download | ab97e82fdf59537d33f1e71c976bd6e481c35050da25a3f663113875caf63895 |
| 0.3.0 | 2020-09-20T13:05:59.878051Z | Download | 05a899caf2d87d2c58edaccee287368d61510af241be4ca3d9e17b61f891576c |
| 0.4.0 | 2020-09-21T13:14:42.392222Z | Download | f89860813edbb3b33a08b4769ea0d3ee30d85a871ca428b09af5a909a7cbf026 |
| 0.4.1 | 2020-09-22T13:35:12.816226Z | Download | bebe433866472311139b02b21138615a6c61e03c99614b518a1372550332e436 |
| 1.0.0 | 2021-01-18T00:19:20.052099Z | Download | 6648704ae3fe26a74e792fff7befb2908bd71129a53b661435fe1aa2ffb27b1e |
| 1.1.0 | 2021-01-19T11:36:06.041207Z | Download | 41d9de908fb58b9acca8c0c05991f93a463b50d3a0be0f065cbfa89d788db624 |
| 1.2.0 | 2021-01-19T12:22:31.244163Z | Download | d21e195d1462c556249054ffe71e97318eb46ee18d5bf08f4da6e7eddf320fbd |
| 1.3.0 | 2021-01-21T05:54:35.762023Z | Download | 794cdfcba98917ec2b8550f33f6ab7dc8af65e0f122e96efac9f186399671d6a |
| 1.3.1 | 2021-02-03T04:01:00.356019Z | Download | 84e0e06a7892d0cc840b5b8fc9117e0623656ec427307cb5ca6472b7010fdc2a |
| 1.3.2 | 2021-02-03T05:02:01.775892Z | Download | 3c590798d778857c0cee60f4c13ea2438bf327bcd3a9d4ee2e91a761dca4cc63 |
| 1.3.3 | 2021-02-15T23:17:03.133852Z | Download | 360942fa877af33bffe73fb76a75a84f13672c7378bb271e02809d6a68b4bae4 |
| 1.3.4 | 2021-02-15T23:57:24.282186Z | Download | 031639fc453297bdd79df6dc5120f2c93bf53cc7b5f89184d3941ba86b21821c |
| 2.0.0-nullsafety.1 | 2021-02-17T02:11:54.352499Z | Download | f57849fa2149e53efeb677e4cbeb1917191eed34e59dd686a0c11e8bb0f44983 |
| 2.0.0 | 2021-02-18T22:27:44.593380Z | Download | 64c1b8e4448812aa564ae5970e77dce69080a26edaebcd11c77df10e1ab4c9b3 |
| 2.1.0 | 2021-05-09T13:04:00.915170Z | Download | 71dce0b71366ed61d8cbb4fd3a8e800dae9f942a233e12b181c2364889e74121 |
| 2.1.1 | 2021-06-06T11:53:20.478833Z | Download | 716e9e522b0b32bafff8067c965d2aa51c0ed5d370c2dd4f86afbe4910ff5050 |
| 2.1.2 | 2021-06-06T11:57:03.009598Z | Download | a2e49609883a8fd97e905b43bc4ee526463672ed28eea38d40d68f2afbd84c69 |
| 2.2.0 | 2021-11-03T11:44:34.566383Z | Download | a152a49b66fb86194bff5031e3ed4fd2e29db139aba728b808e17fb29e128862 |
| 2.2.1 | 2021-11-17T03:14:00.576621Z | Download | 59cd50f48a81ec5bbca3e6a34e659500f7422f8cb56936aa790202708153f145 |
| 2.2.2 | 2021-12-02T02:20:04.382149Z | Download | 5fca68d247bda9e7fdfdd4637f5fd90646b69a9d171d60c5d37cbfbf6966766d |
| 2.2.3 | 2021-12-07T20:36:39.399217Z | Download | 6446ba818315c21e0fab0c638d3a45948c4d473a11761bdd1782c00305de98a6 |
| 3.0.0 | 2021-12-13T21:23:44.399333Z | Download | a5708ed769316ea877ad99d002f20d9e20401f99da01cb360b7c4cc53db3c395 |
| 3.1.0 | 2022-04-11T07:13:29.430528Z | Download | 8ef816a60077a3be3bbb20a3fac32e642c24f8a6d79ffc3ad3b2b84d9063b9e7 |
| 4.0.0 | 2022-07-13T00:12:23.087792Z | Download | 658671e46ef694ef907465719a33aa6745c4a80e34cc49e53eb4a7d4363acd89 |
| 4.0.1 | 2022-10-14T21:36:46.298596Z | Download | b1c7bba4fa7788a9db2e922b7823003f5a720b928e7b0a274e7d8285ca3ce6bf |
| 4.1.0 | 2022-10-21T21:08:50.610748Z | Download | 203e3ad9df376927118dc662e1724dde1f64e2c3292cd59a8082d4a2de84bb70 |
| 5.0.0 | 2023-05-12T22:35:07.676799Z | Download | 3ad26924254fd2354b0e2b95fc8b45ac392ad87434f8e64807b3a1ac077f2256 |
| 6.0.0 | 2023-11-14T23:21:00.124586Z | Download | b9951567834165152e5e78c42f3f91d7f94616a498ff0c172680eda07b65c9a6 |
| 6.0.1 | 2023-11-14T23:42:26.992335Z | Download | a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a |
| 6.0.2 | 2025-04-18T00:11:42.791090Z | Download | f0d7856b6ca1887cfa6d1d394056a296ae33489db914e365e2044fdada449e62 |
| 6.0.3 | 2025-06-28T02:01:27.604416Z | Download | 6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61 |
| 6.5.0 | 2026-02-22T07:58:49.581102Z | Download | 185ef7606574f789b40f289c233efa52e96dead518aed988e040a10737febb07 |
| 6.5.1 | 2026-07-24T00:13:14.434661Z | Download | bebff4a1df009c2331c08ffb3a3b9e8f26733b4a0de34b23dbb07b1b8af21979 |
| 6.5.2 | 2026-07-24T02:47:24.716697Z | Download | bc1bad54ad2b735816e31f8d4600cfde6c7839975085ddfbca48b6c9f7c4044e |
| 6.5.3 | 2026-10-25T20:10:22.272414Z | Download | 6312deb534ce3812a1b454143740ffe721a17dc3a33bfc978f3a6d7bc5833edf |
| 6.5.4 | 2026-10-28T02:04:07.999185Z | Download | 613646d076944f3acc125830af935b48d4b8a57a388691547bbfd25b434f4d63 |
Dependencies
ffi "^1.0.0"