Opening write stream problem in BlitzmaxNG?

Started by Baggey, September 07, 2024, 18:59:18

Previous topic - Next topic

Baggey

Quote from: Dabz on September 08, 2024, 22:26:42Ideally, you should be writing these things to somewhere in the appdata folder... Only problem is, they've mucked about with how to actually get these things so many times, I now just use this (On Windows):-

char* GetEnvAppDataPath()
{
return(getenv("APPDATA"));
}

Which you plonk in a C file, then import said C file in your Blitzmax source, e.g.

Import "c_code.c"

Then to use it in Blitzmax:-

Extern
Function GetEnvAppDataPath:Byte Ptr()
End Extern

Local appDataPath:String = String.FromCString(GetEnvAppDataPath())
Print "*"+appDataPath+"*"
End

Bare in mind, this isnt the "safest" way, not in a security sense, but valid path sense, I've had no bother with it at all though, but, consider checks on the returned path none the less, I also have another one which returns the users temp folder, just replace the "APPDATA" string with "TEMP", and in goes your eye out. <--- And before anyone asks, why don't I just pass a string with the name of the special folder and have something like SystemProperty("BLAH") like other Blitz languages... All I can say is, meh! :P

Dabz

I would love to see more examples of how to integrate with C ;)

Baggey
Running a PC that just Aint fast enough!? i7 4Ghz Quad core 32GB ram  2x1TB SSD and NVIDIA Quadro K1200 on Acer 24" . DID Technology stop! Or have we been assimulated!

Windows10, Parrot OS, Raspberry Pi Black Edition! , ZX Spectrum 48k, C64, Enterprise 128K, The SID chip. Im Misunderstood!

Henri

Hi,

you can get environment variable directly from Blitzmax

Code (blitzmax) Select
Print getenv_("TEMP")
Print getenv_("USERNAME")
Print getenv_("APPDATA")

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Dabz

#17
Quote from: Henri on September 09, 2024, 11:53:16Hi,

you can get environment variable directly from Blitzmax

Code (blitzmax) Select
Print getenv_("TEMP")
Print getenv_("USERNAME")
Print getenv_("APPDATA")

-Henri
well, I was todays years old when I found that out... I didnt know it existed because I'm sure once I needed it, and for love nor money could I find it... But then, I never give the _ character a thought... Oh well, live and learn! :)

@Ron
Handy to know geezer! Nice one, but I'll be honest, I would never have thought to look in volumes for Filesystem stuff (I know they are related some what, but, for paths, I would of just took a peek in Filesystem.bmx where you have CurrentDir() etc etc

Dabz
Intel Core i5 6400 2.7GHz, NVIDIA GeForce GTX 1070 (8GB), 16Gig DDR4 RAM, 256GB SSD, 1TB HDD, Windows 10 64bit

Derron

Yeah, maybe we should suggest to move that functionality into "filesystem.mod" - albeit I am not sure how much that collides with "brl.io" then (which is a virtual filesystem layer on top of filesystem.mod stuff). What I mean is: brl.io covers to virtualize the brl.filesystem stuff - but am not sure about the brl.volumes functionality.


bye
Ron