패키지, 저장소 및 앱 카테고리 검색

패키지 상세v6.5.4

posix

OSx 및 Linux에서 POSIX API 노출

AndroidiOSmacOSWindowsLinux
30일 다운로드
935만
좋아요
12
Pub 점수
160

패키지 설치

flutter pub add posix

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

posix 패키지는 macOS 및 Linux에서 POSIX 시스템 API에 대한 액세스를 제공하여 파일 조작, 프로세스 제어, 시그널 처리와 같은 저수준 시스템 작업을 가능하게 합니다. 기본 운영 체제와 직접 상호 작용이 필요한 데스크톱 애플리케이션을 위해 설계되었습니다. 이 패키지는 Dart 인터페이스를 통해 네이티브 POSIX 함수를 노출하여 고급 시스템 프로그래밍 작업에 적합합니다. macOS, Linux, Windows, Android 및 iOS 플랫폼을 지원하지만, 완전한 POSIX 기능은 주로 macOS 및 Linux에서 사용 가능합니다. 시스템 리소스에 대해 세밀한 제어가 필요한 도구를 개발하는 개발자에게 이상적입니다.

사용 사례

  • 시스템 수준 파일 작업
  • 프로세스 및 스레드 관리
  • 데스크톱 앱에서의 시그널 처리
  • 크로스 플랫폼 시스템 유틸리티
  • 저수준 OS 상호작용

주요 기능

  • 네이티브 POSIX API 접근
  • macOS 및 Linux 지원
  • 크로스 플랫폼 호환성
  • 시스템 호출을 위한 Dart 친화적인 래퍼
  • 경량화되고 집중적인 디자인

적합한 대상

  • 데스크톱 애플리케이션 개발자
  • 시스템 도구 제작자
  • 고급 플러터 사용자
  • 운영체제 수준의 접근이 필요한 개발자
  • 프로세스 격리가 필요한 도구

고려 사항

  • 비-POSIX 플랫폼에서 기능 제한
  • 플랫폼에 특화된 지식이 필요합니다
  • 모바일 앱 핵심 로직용이 아님
  • 권한을 상승시켜야 할 수 있습니다
  • 데스크톱 환경 전용으로 가장 적합

원본 README

연결된 소스 저장소의 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.

카테고리

의존성

의존성 목록 3 개

소스 저장소

이 패키지를 사용하는 프로젝트