Kotlin / kotlinx-io

Kotlin multiplatform I/O library
Apache License 2.0
1.23k stars 56 forks source link

Web crash `get_os().platform() == 'win32'` #394

Open raspberry-jenshen opened 1 day ago

raspberry-jenshen commented 1 day ago

Hello!

Thank you for your cool package!

I faced issues when I converted my Kotlin code to the web platform (JS).

My code:

internal class FileSystemImpl(
    private val fileSystem: KotlinFiles = SystemFileSystem,
) : FileSystem {

The crash: platform undefined

The crash happens when FileSystemImpl is created.

// JS code
var properties_initialized_FileSystemJs_kt_lg8f5i;
  function _init_properties_FileSystemJs_kt__4boaac() {
    if (!properties_initialized_FileSystemJs_kt_lg8f5i) {
      properties_initialized_FileSystemJs_kt_lg8f5i = true;
      SystemFileSystem = new SystemFileSystem$1();
      // crash is here
      isWindows = get_os().platform() == 'win32';
    }
  }
fzhinkin commented 1 day ago

@raspberry-jenshen SystemFileSystem is not supported for JS/Browser. It's supported only for NodeJS environment.