refactor os imports into corresponding small modules (#20720)

This commit is contained in:
ringabout 2022-11-01 17:18:04 +08:00 • committed by GitHub
commit 6166b796ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 8 deletions

View file

@ -24,8 +24,9 @@ when declared(math.signbit):
from std/envvars import getEnv, existsEnv, delEnv, putEnv, envPairs from std/envvars import getEnv, existsEnv, delEnv, putEnv, envPairs
from std/os import walkDir, getAppFilename from std/os import getAppFilename
from std/private/oscommon import dirExists, fileExists from std/private/oscommon import dirExists, fileExists
from std/private/osdirs import walkDir
from std/times import cpuTime from std/times import cpuTime
from std/hashes import hash from std/hashes import hash

View file

@ -31,7 +31,7 @@ from std/strutils import contains, toLowerAscii
when not defined(nimscript): when not defined(nimscript):
from std/osproc import execProcess from std/osproc import execProcess
from std/os import existsEnv from std/envvars import existsEnv
type type
Distribution* {.pure.} = enum ## the list of known distributions Distribution* {.pure.} = enum ## the list of known distributions

View file

@ -24,7 +24,8 @@ elif defined(posix):
else: else:
{.error: "the memfiles module is not supported on your operating system!".} {.error: "the memfiles module is not supported on your operating system!".}
import os, streams import streams
import std/oserrors
when defined(nimPreviewSlimSystem): when defined(nimPreviewSlimSystem):
import std/[syncio, assertions] import std/[syncio, assertions]

View file

@ -18,7 +18,7 @@
## ##
## Unstable API. ## Unstable API.
from os import raiseOSError, osLastError from std/oserrors import raiseOSError, osLastError
template distance*(lhs, rhs: pointer): int = template distance*(lhs, rhs: pointer): int =
cast[int](rhs) - cast[int](lhs) cast[int](rhs) - cast[int](lhs)

View file

@ -27,7 +27,8 @@
## ##
## TODO: `/dev/poll`, `event ports` and filesystem events. ## TODO: `/dev/poll`, `event ports` and filesystem events.
import os, nativesockets import nativesockets
import std/oserrors
when defined(nimPreviewSlimSystem): when defined(nimPreviewSlimSystem):
import std/assertions import std/assertions

View file

@ -61,7 +61,7 @@ when defined(js) or defined(nimscript) or defined(Standalone):
{.pragma: rtlFunc.} {.pragma: rtlFunc.}
else: else:
{.pragma: rtlFunc, rtl.} {.pragma: rtlFunc, rtl.}
import os import std/envvars
include "system/inclrtl" include "system/inclrtl"

View file

@ -57,7 +57,7 @@ runnableExamples:
when not defined(js): when not defined(js):
import os import std/oserrors
when defined(posix): when defined(posix):
import posix import posix

View file

@ -9,7 +9,7 @@
## This module is experimental and its interface may change. ## This module is experimental and its interface may change.
import winlean, os import std/oserrors
when defined(nimPreviewSlimSystem): when defined(nimPreviewSlimSystem):
import std/widestrs import std/widestrs