AZO234 / NP2kai

Neko Project II kai
http://domisan.sakura.ne.jp/article/np2kai/np2kai.html
MIT License
246 stars 61 forks source link

Bug fix on hostdrv function #116

Closed miyamoto999 closed 2 years ago

miyamoto999 commented 3 years ago

hostdrv機能がおかしかったので直してみました。

不具合

  1. SDL2ポートのmacOS、Linux、libretroポートのmacOS、LinuxでDIRを実行するとファイルサイズが0になる。
  2. SDL2ポートのmacOS、Linux、libretroポートのmacOS、Linuxでサブディレクトリのファイル一覧が表示されない。
  3. Windows(VS2019ビルド)ポートでDIRを実行するとファイル一覧が表示されない。
  4. Xポートでrmdirをするとエラーになる。(rmdir前にディレクトリがあることは確認済み)
  5. libretroポートでmkdirするとエラーになる。(mkdir前にディレクトリがないことは確認済み)

なお、libretroのWindowsは":"が入力できなかったので未確認。libretroのAndroid/iOS、Emscripten、OpenDinguxは諸般の事情により未確認。(面倒くさかったとも言う😅)

変更点

  1. ファイル情報を取得するstat()関数にファイル名のみ渡していたため、ファイル情報を取得できていなかったのでフルパスを渡すようにした。libretroポートはそもそもファイルサイズを設定していなかったので設定するようにした。タイムスタンプは取得関数がわからなかったので未対応。
  2. Linux、macOSでDOSパスの区切りを'/'で判定していたため、正しく処理できていなかった。'\'で判定するようにした。
  3. FindFirstFileW()関数に渡すファイルパスが間違っていたので改修した。ファイル名をutf8からsjisへ変換するためのoemtext_utf8tomb()関数の中でcodecnv_utf8toucs2()関数で文字数を取得しようとしているが、それは文字数を取得するのに対応していなかった。ので対応した。
  4. remove()関数の成功/失敗判定が逆だったのを改修。
  5. path_mkdir()関数の成功/失敗判定が逆だったのを改修。

念のためもう一度書いておきますが、libretroポートでのタイムスタンプ取得APIがわからなかったのでファイルのタイムスタンプの設定は未対応です。

一応、英語も書いておくけどかなり翻訳ツールの力を借りてしまった😅


There was a problem with hostdrv and I fixed it.

Problem

  1. When executing DIR on macOS or Linux with the SDL2 port, or on macOS or Linux with the libretro port, the file size is displayed as 0.
  2. The list of files in subdirectories is not displayed on macOS and Linux with the SDL2 port and on macOS and Linux with the libretro port.
  3. When executing DIR on a Windows (VS2019 build) port, the file list is not displayed.
  4. When executing rmdir on the X port, an error occurs. (The directory was found before executing rmdir)
  5. When executing mkdir on the libretro port, an error occurs. (The directory wasn't found before executing mkdir.)

I haven't checked libretro's Windows because I couldn't type ":". libretro's Android/iOS, Emscripten and OpenDingux haven't checked for some reasons.(It was only troublesome.😅)

Changes

  1. The stat() function could not get the file information because it only passed the file name to the stat() function.Therefore, I gave the fullpath. The libretro port didn't set the file size, so I set it.Timestamp has not been supported because I didn't understand the get function.
  2. On Linux and macOS, the DOS path was judged by '/' as a delimiter of the DOS path, so it was not handled correctly.Judged by '\'.
  3. Fixed a mistake in the file path passing to FindFirstFileW() function.I'm trying to get the number of characters in the codecnv_utf8toucs2() function in the oemtext_utf8tomb() function to convert the file name from utf8 to sjis, but it didn't support getting the number of characters. So I supported it.
  4. Fixes the success/failure judgment of the remove() function was reversed.
  5. Fixes the path_mkdir() function's success/failure judgment in reverse.

Just to reiterate, I didn't know the API to get the timestamp on the libretro port. So setting the timestamp for the file is not yet supported.

miyamoto999 commented 3 years ago
動作確認してみました。                 
SDL1-macOS *1
SDL1-Linux *2
SDL1-Win o
SDL2-macOS o
SDL2-Linux o
SDL2-Win o
Windows(VS2019ビルド) o
X11-SDL1 o
X11-SDL2 o
libretro-macOS o *3
libretro-Linux o *3
libretro-Win *2
libretro-Android *4
libretro-iOS *4
Emscripten
OpenDingux

1 そもそも正しく動作しない。 2 ':'(コロン)が入力できず未確認。 3 libretroにファイルのタイムスタンプを取得するAPIが見当たらなかったので更新日時を設定していないため、MS-DOSのDIRコマンドでファイルの更新日時が表示されない以外は問題なし。 4 ビルドのみ確認

空白 開発環境が手元にないので未確認