Duplicating workbench pathlist

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 6:47 pm
Contact:

Duplicating workbench pathlist

Post by JosDuchIt »

What is presently the recommended way to duplicate the WB pathlist for applications started from WB that do launch CLI commands without the full path ?

Starting from a 2006 thread http://www.amigacoding.de/index.php?topic=142.0 (REf 1)
it seems programmers make use of one of the following approaches

1. Ralph Babel's cloneWorkBenchPath() function (the gui4Cli launcher "Gui" does) (renamed "gui4" to avoid confusion withthe gui oS4 preferences program"
http://aminet.net/package.php?package=d ... wbpath.lha

It is probably described in his Guru book, which i don't possess
In the thread Thomas explains:

It uses WBStartup->sm_Message.mn_ReplyPort->mp_SigTask->pr_CLI->cli_CommandDir to get a pointer to the Workbench's path list and then clones it by calling DupLock for each node.

To be noted: cli_CommandDir has been replaced cli_PathList since ...

2. Using workbench.library/WorkbenchControlA(
WBCTRLA_DuplicateSearchPath (BPTR *) -

Ref 1 geit, mentions that the following fails under OS4
if( WorkbenchBase->lib_Version >= 44 ) {
WorkbenchControl( NULL, WBCTRLA_DuplicateSearchPath, &path, TAG_DONE );
}

SystemTags( name, NP_StackSize, stack,
SYS_Output, ohandle,
SYS_Input, ihandle,
SYS_Asynch, TRUE,
NP_Path, path,
TAG_DONE );

docommands.h
SystemTags(marg[0].str, SYS_Input, NULL, SYS_Output, conout, NP_StackSize, usestack, TAG_END);


3. Using AllocDosObjectTaglis(DOS_CLI,NULL)
Ref 1:oBarthel:
" Here's what all those Workbench programs do which clone the Workbench path list (e.g. the "CLI" program in "SYS:System"):
struct CommandLineInterface *cli;

cli = AllocDosObjectTagList(DOS_CLI,NULL);

process->pr_CLI = MKBADDR(cli);
process->pr_Flags |= PRF_FREECLI;



Just make sure that you don't overwrite an existing CLI structure, or you'll get the shell into big trouble your program was launched from. Put another way, make sure you don't attempt to clone the search path unless you were really launched by Workbench."

If it's method 3 , could an example be given ?
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 534
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland
Contact:

Re: Duplicating workbench pathlist

Post by salass00 »

I use the following code in my AutoRun commodity:

Code: Select all

void ExecuteAutoRun (CONST_STRPTR command) {
	BPTR path = ZERO;
	BPTR stdin, stdout, stderr;
	int32 error;
	IWorkbench->WorkbenchControl(NULL,
		WBCTRLA_DuplicateSearchPath, &path,
		TAG_END);
	stdin = IDOS->Open("NIL:", MODE_OLDFILE);
	stdout = IDOS->Open("NIL:", MODE_OLDFILE);
	stderr = IDOS->Open("NIL:", MODE_OLDFILE);
	if (stdin && stdout && stderr) {
		error = IDOS->SystemTags(command,
			NP_Name,		"AutoRun Script",
			SYS_Asynch,		TRUE,
			NP_Path,		path,
			NP_CloseError,	TRUE,
			SYS_Input,		stdin,
			SYS_Output,		stdout,
			SYS_Error,		stderr,
			TAG_END);
		if (error != -1) {
			return;
		}
	}
	if (path != ZERO) {
		IWorkbench->WorkbenchControl(NULL,
			WBCTRLA_FreeSearchPath, path,
			TAG_END);
	}
	IDOS->Close(stdin);
	IDOS->Close(stdout);
	IDOS->Close(stderr);
}
Note that I duplicate the path list mainly for commands inside the AutoRun script. I use full path for the execute command as there is no reason for me not to do so ("C:Execute").
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 6:47 pm
Contact:

Re: Duplicating workbench pathlist

Post by JosDuchIt »

@salass00

Thanks a lot
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1483
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: Duplicating workbench pathlist

Post by tonyw »

salass00 wrote: Note that I duplicate the path list mainly for commands inside the AutoRun script. I use full path for the execute command as there is no reason for me not to do so ("C:Execute").
Are you sure about that? There is no such thing as "C:Execute". "Execute" is an internal Shell command.
cheers
tony
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 534
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland
Contact:

Re: Duplicating workbench pathlist

Post by salass00 »

Are you sure about that? There is no such thing as "C:Execute". "Execute" is an internal Shell command.
Yes, you are right. Execute is a internal resident command in AmigaOS 4.1. I assume this was a change made in AmigaOS 4.0/4.1 because checking my FS-UAE AmigaOS 3.1 install I do have an Execute command in C: there.

Since the command is resident on AmigaOS 4.1 the path ("C:") doesn't matter at all then as only the file name portion ("Execute") is used when checking for resident commands.
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1483
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: Duplicating workbench pathlist

Post by tonyw »

"Execute" is present also in WB3.9:C, so it must have been absorbed into the Shell in 4.0.
cheers
tony
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1744
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Duplicating workbench pathlist

Post by nbache »

tonyw wrote:"Execute" is present also in WB3.9:C, so it must have been absorbed into the Shell in 4.0.
Yep, 51.24 from 7.1.2005. I believe the first public version with Execute integrated was with 4.0 update 3?

Best regards,

Niels
Post Reply