Cj-bc / 3dShell

0 stars 0 forks source link

Create shellscript to gather file informations on linux/macOS #2

Open Cj-bc opened 4 years ago

Cj-bc commented 4 years ago

C# provides methods to treat files/directories on Windows, but not for other OS. searching for a while, I noticed I should make these by myself.

what script should do

  1. Collect informations about files/directories under pwd
  2. Serialize them to JSON
  3. echo to stdout

how to execute this from C

By making Process. for details, here's Microsoft C# document for Process

working flow

  1. Determine OS
  2. If OS == Windows, use C# code otherwise execute the script
  3. Script collect required informations and echo to stdout
  4. Catch stdout on C# side
  5. Deserialize it with JsonUtility.FromJson

Why do we use JSON to pass data

Because it's easier to have structured data format, and easy to make from sh. And because Unity supports json serialize/desirialize

Cj-bc commented 3 years ago

ソンナコトナイヨ System.FileSystemInfo でmacは取得できたよ GNU/Linux環境は知らないよ(ビルドしたのちにダメだったらまた考えるよ)(そもそもQuestとかに持ってくことにしたので今あんま関係ない気がするよ)