CreateDirectory - I can't get it to work

Linux specific forum
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

CreateDirectory - I can't get it to work

Post by Straker »

Here's my code:

Code: Select all

gMyDir.s = "~/mydir"
Debug CreateDirectory(gMyDir.s)
Always returns 0

The problem lies in the "~" which is the wildcard to the home directory. It works with a fully qualified path, i.e. "/home/user/mydir", but I won't know this so how can I achieve this directory creation with the wildcard?

Thanks
Image Image
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Why not simple use:

Code: Select all

gMyDir.s = GetHomeDirectory() + "mydir"
Debug CreateDirectory(gMyDir.s) 
?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

~ is expanded by the shell. It's not a part of the filesystem. PB's file commands doesn't go through a shell.
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

GetHomeDirectory() worked.

Thanks for the tips guys.
Image Image
Post Reply