FLUTTER ECOSYSTEM

onepub-dev/dart_posix

onepub-dev/dart_posix open-source repository details.

dart_posix 프로젝트 이미지
Stars
14
Forks
6
최근 푸시(UTC)
2026. 7. 24.
프로젝트 상태
활성
OnePub GitHub avatar
GITHUB Organization

OnePub ↗

언어DartShell

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 11 개
  • ffi^2.0.1
  • meta^1.7.0
  • path^1.8.3
  • cli_script개발 의존성^1.0.0
  • ffigen개발 의존성^18.1.0
  • lint_hard개발 의존성^6.0.0
  • logger개발 의존성^2.5.0
  • logging개발 의존성^1.1.1
  • stack_trace개발 의존성^1.11.0
  • test개발 의존성^1.16.2
  • uuid개발 의존성^4.5.1

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

Provides Dart access to the POSIX api for MacOS 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 error codes.

Often posix will return null and then expect you to make a separate call to 'errorno' to get the actual 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:

  1. Install ffigen
dart pub global activate ffigen
  1. 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
  1. find the required posix header file

  2. use ffigen to create the initial dart file from the header.

    • add your header file to ffigen.yaml
  3. Run ffigen

dart pub run ffigen  --config ffigen/linux.yaml 
  1. convert each method to take/return dart types.