Autor Tema: behaviour of fileinfo windows v.s. linux  (Leído 1153 veces)

handsource-dyko

  • Hero Member
  • *****
  • Mensajes: 568
  • Karma: 32
  • I'm the eye in the sky.
    • dyko designs
behaviour of fileinfo windows v.s. linux
« en: Enero 30, 2011, 02:11:13 pm »
I've noticed that under windows, a "\" is added at the end of the path. So when I add the fileinfo.path and fileinfo.name strings together I get "C:\bennu\test\test1.prg".
under linux this would result int to "/home/pieter/bennu/testtest1.prg", so I need to add a "/", obviously it should be "/home/pieter/bennu/test/test1.prg"

Because fileinfo.path under windows is  "C:\bennu\test\" and under linux it is "/home/pieter/bennu/test" Why does this behave differently? I've found out after a lot of
frustation with my latest creation, a bennu based file selection dialog box.

Is it just a platform specific thing? There is nothing about this different behaviour on the wiki.

Also, how is the behaviour under other operation systems like macos/haiku os/gpwiz/caanoo? I suspect a linux like behaviour, thinking
windows is different from the rest.
« última modificación: Enero 30, 2011, 02:36:43 pm por handsource-dyko »

FreeYourMind

  • Hero Member
  • *****
  • Mensajes: 5674
  • Karma: 127
    • GECA soft
Re: behaviour of fileinfo windows v.s. linux
« Respuesta #1 en: Enero 30, 2011, 04:11:39 pm »
You never must use '\' in a path, this is compatible only with windows. Use always '/' and you don't have problems in any SO.

handsource-dyko

  • Hero Member
  • *****
  • Mensajes: 568
  • Karma: 32
  • I'm the eye in the sky.
    • dyko designs
Re: behaviour of fileinfo windows v.s. linux
« Respuesta #2 en: Enero 30, 2011, 08:01:49 pm »
I suppose that "/" is the posix compatibe way? Anyway, it works now. Another windows oddity though, are drive letters. On linux or unix style os's this handled in a much more elegant way, namely that drives are mounted in the main tree. Only for windows I have to add extra code for drive selection, even though under the hood, modern windows versions also seem to use this sceme, but still maintain the antiquated drive letter concept! (At least for users, windows xp is supposed to be posix compatibe).

josebita

  • Administrator
  • *****
  • Mensajes: 4039
  • Karma: 257
    • BennuGD Mobile Worklog
Re: behaviour of fileinfo windows v.s. linux
« Respuesta #3 en: Enero 30, 2011, 11:17:41 pm »
I believe most OSes use linux-like file-system scheme. Anyway, just to be sure, always use "/" as foldeer separator and if in doubt, it won't hurt to have double slashes. I mean that when generating paths programmatically, using a path like:
/home/joseba/mygame//myfile.png
will work just fine, so always add a slash, if in doubt.