MakeDirectory()

Find quick help here to get you started with Hollywood
Post Reply
User avatar
NubeCheCorre
Posts: 56
Joined: Mon Mar 19, 2012 1:24 am
Contact:

MakeDirectory()

Post by NubeCheCorre » Fri Sep 06, 2019 1:38 am

Hi,
I'd like to know if there is a way to create a directory using the function: MakeDirectory() with an icon attached to it so that the directory is visible and not "ghosted".. I am using Hollywood 6.0
Thanks

amyren
Posts: 81
Joined: Thu May 02, 2019 11:53 am

Re: MakeDirectory()

Post by amyren » Fri Sep 06, 2019 10:44 am

This should work. (I asume that that you are compilng for Amiga systems here)
You will need to have a standard folder icon file, eg. named folder.info, and put it into a folder named icons in the same folder as your .hwp file before compiling.
Note that the first line is a preprocessor command and should be placed at the beginning of your script.

Code: Select all

@DIRECTORY 1, "icons" ;include the files from the icons folder into your application
MakeDirectory("Test") ; creates the folder
CopyFile(GetDirectoryEntry(1, "folder.info"), "" ,"Test.info") ; copy and rename the folder.info file into desired location.
you can also use variables in there if you prefer:

Code: Select all

@DIRECTORY 1, "icons" 
myfoldername$ = "Test"
foldericonname$ = myfoldername$..".info"
MakeDirectory(myfoldername$) 
CopyFile(GetDirectoryEntry(1, "folder.info"), "" ,foldericonname$) 
Alternatively, if the system you are compiling for supports png icons, you could just have any .png image file and rename to an .info file.

User avatar
NubeCheCorre
Posts: 56
Joined: Mon Mar 19, 2012 1:24 am
Contact:

Re: MakeDirectory()

Post by NubeCheCorre » Sun Sep 08, 2019 12:57 am

Thanks for the informations and sorry for my late reply but unfortunatly these funtions are not available under Hollywood 6.0
Thanks,

amyren
Posts: 81
Joined: Thu May 02, 2019 11:53 am

Re: MakeDirectory()

Post by amyren » Sun Sep 08, 2019 9:01 am

NubeCheCorre wrote:
Sun Sep 08, 2019 12:57 am
Thanks for the informations and sorry for my late reply but unfortunatly these funtions are not available under Hollywood 6.0
Thanks,
I see, @DIRECTORY did come with 8.0

But @FILE should also be able to link a file into the application, but I did not get that to work with CopyFile

Unless there is a way around that, you might have to have that folder.info file included with your application, and just use it like this.

Code: Select all

MakeDirectory("Test") ; creates the folder
CopyFile("folder.info"), "" ,"Test.info")

User avatar
jPV
Posts: 277
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: MakeDirectory()

Post by jPV » Sun Sep 08, 2019 9:45 am

This is generally a bit problematic, because if you link your own drawer icons, then they won't be consistent with other icons in each system...

To preserve consistency on users' system, you could try to copy a drawer icon from system's deficons, but that location might be different on different platforms/configs...

User avatar
jPV
Posts: 277
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: MakeDirectory()

Post by jPV » Sun Sep 08, 2019 10:30 am

I guess something like this should work in the most cases:

Code: Select all

@FILE 1, "my_drawer.info"

Function p_MakeDir(path$, newdir$)
    newdir$ = TrimStr(newdir$, "/", True)
    Local fullpath$ = FullPath(path$, newdir$)
    If (HaveVolume(path$) Or Exists(path$)) And Not Exists(fullpath$)
        MakeDirectory(fullpath$)
        If Exists("ENVARC:sys/def_drawer.info")
            CopyFile("ENVARC:sys/def_drawer.info", path$, newdir$ .. ".info")
        ElseIf Exists("SYS:Prefs/Presets/Deficons/def_drawer.info")
            CopyFile("SYS:Prefs/Presets/Deficons/def_drawer.info", path$, newdir$ .. ".info")
        Else
            StringToFile(ReadString(1), fullpath$ .. ".info")
        EndIf
    EndIf
EndFunction

p_MakeDir("RAM:", "New Directory")

amyren
Posts: 81
Joined: Thu May 02, 2019 11:53 am

Re: MakeDirectory()

Post by amyren » Sun Sep 08, 2019 5:10 pm

That seemes to work. I only tested on windows though.

Interesting that StringToFile does work like that, copying the content of the info file and creates a new file with the same content. I though that stringtofile only worked with textfiles, but apearently it does more than that.

But why will not copyfile work with the linked file as source?

User avatar
jPV
Posts: 277
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: MakeDirectory()

Post by jPV » Sun Sep 08, 2019 8:50 pm

amyren wrote:
Sun Sep 08, 2019 5:10 pm
Interesting that StringToFile does work like that, copying the content of the info file and creates a new file with the same content. I though that stringtofile only worked with textfiles, but apearently it does more than that.
Strings can also store binary data in Hollywood, there aren't any other data types for that.

And btw, maybe it would be better to use this with later Hollywoods (to avoid any problems with UTF-8 support):
StringToFile(ReadBytes(1), fullpath$ .. ".info")

But IIRC ReadBytes wasn't available in 6.0. And it might have been that in 6.0 ReadString needed the length argument too... can't remember for sure, but if it's the case, then something like this for it:
StringToFile(ReadString(1, FileLength(1)), fullpath$ .. ".info")

But why will not copyfile work with the linked file as source?
It only handles files on the filesystem, not open files. Linked file acts as an opened file and you can't refer it directly but only read from it by its handle (ID).

User avatar
NubeCheCorre
Posts: 56
Joined: Mon Mar 19, 2012 1:24 am
Contact:

Re: MakeDirectory()

Post by NubeCheCorre » Sun Sep 08, 2019 9:31 pm

Thanks, it works! :-)

Post Reply