Click Here
home features news forums classifieds faqs links search
6071 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
8 crawler(s) on-line.
 99 guest(s) on-line.
 2 member(s) on-line.


 Hammer,  davebraco

You are an anonymous user.
Register Now!
 davebraco:  28 secs ago
 Hammer:  4 mins ago
 kolla:  7 mins ago
 vox:  20 mins ago
 Musashi5150:  27 mins ago
 bhabbott:  1 hr 55 mins ago
 matthey:  2 hrs 15 mins ago
 Hypex:  2 hrs 32 mins ago
 DiscreetFX:  2 hrs 37 mins ago
 eliyahu:  5 hrs 1 min ago

/  Forum Index
   /  Amiga Development
      /  Dos.library SystemTags & FileInfoBlock
Register To Post

Goto page ( 1 | 2 | 3 | 4 Next Page )
PosterThread
AmiDARK 
Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 16:30:33
#1 ]
Regular Member
Joined: 28-Mar-2007
Posts: 469
From: South France

Hello.

do someone have any sample showing how I can use SystemTags function to execute a cli program from my C application ?
Same for FileInfoBlock. I need to use it to get a file creation date & last changes date.

Can someone help please ?

Thank you.

Regards,

 Status: Offline
Profile     Report this post  
Ami603 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 17:32:29
#2 ]
Cult Member
Joined: 7-Mar-2003
Posts: 580
From: Valencia,Spain 8-)

@AmiDARK


/*
** RunCmd V1.0
** Launches Asyncronously a shell command, while retaining
** all the console output in a listbrowser.
**
** Dependencies:
** Exec,DOS,Utility,Intuition,ListBrowser,(Layout?)
**
** Should be Fully Reentrant,(I HOPE) no global data is used.
**
** Inputs:
** Name: Name of the command to launch
** Out: ListBrowser nodes list
** Gad: ListBrowser gadget pointer
** Win: ListBrowser Window pointer
** Retuns:
** Nothing.
** TODO:
** Maybe returning some error codes
** Modify error output
*/

#include "includes.h"

void RunCmd(CONST_STRPTR Name,struct List *Out,struct Gadget *Gad,struct Window *Win)
{
BOOL done = FALSE;
BPTR InPipe,
OutPipe;
LONG num;
STRPTR Buffer;
struct Node *node;
struct FReadLineData *frld;


if((OutPipe = IDOS->Open("PIPE:CmdOut", MODE_NEWFILE)))
{
if (IDOS->SystemTags(Name,
SYS_Input, NULL,
SYS_Output, OutPipe,
SYS_Error, OutPipe,
SYS_Asynch, TRUE,
TAG_END)!=-1)
{
if ((InPipe = IDOS->Open("PIPE:CmdOut", MODE_OLDFILE)))
{

while ((done == FALSE))
{
if((frld = IDOS->AllocDosObject(DOS_FREADLINEDATA,TAG_DONE)))
{
num = IDOS->FReadLine(InPipe,frld);
if((num > 0))
{
if((Buffer = IExec->AllocVec(frld->frld_LineLength,MEMF_ANY)))
{
IUtility->Strlcpy(Buffer,frld->frld_Line,frld->frld_LineLength);
node = IListBrowser->AllocListBrowserNode(1,
LBNCA_CopyText, TRUE,
LBNCA_Text,Buffer,
TAG_DONE);
if(node)
{
IIntuition->SetGadgetAttrs(Gad,Win,NULL,
LISTBROWSER_Labels, ~0,
TAG_DONE);
IExec->AddTail(Out,node);
IIntuition->SetGadgetAttrs(Gad,Win,NULL,
LISTBROWSER_Labels, Out,
LISTBROWSER_MakeVisible,node,
TAG_DONE);
}
IExec->FreeVec(Buffer);
}
}
IDOS->FreeDosObject(DOS_FREADLINEDATA,frld);
if((num Close(InPipe);
}
else
IDOS->Printf("RunCmd::Failed to open input\n");
}
else
IDOS->Printf("RunCmd::Failed to load command\n");
}
else
IDOS->Printf("RunCmd::Failed to open output\n");
}

Last edited by Ami603 on 16-Jul-2012 at 08:28 PM.

_________________
Cuida tus piedras gordas.

A1200/030 32Mb
A4000D
A1-X1000.

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 18:52:32
#3 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12931
From: Norway

@Ami603

use the "pri" tag to get source code to look nice

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
Ami603 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 19:27:28
#4 ]
Cult Member
Joined: 7-Mar-2003
Posts: 580
From: Valencia,Spain 8-)

@NutsAboutAmiga

Care to show the syntax? thank you.

_________________
Cuida tus piedras gordas.

A1200/030 32Mb
A4000D
A1-X1000.

 Status: Offline
Profile     Report this post  
broadblues 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 20:07:55
#5 ]
Amiga Developer Team
Joined: 20-Jul-2004
Posts: 4447
From: Portsmouth England

@Ami603

<pre>


Source code goes here

</pre>

Last edited by broadblues on 16-Jul-2012 at 08:08 PM.

_________________
BroadBlues On Blues BroadBlues On Amiga Walker Broad

 Status: Offline
Profile     Report this post  
Ami603 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 20:28:39
#6 ]
Cult Member
Joined: 7-Mar-2003
Posts: 580
From: Valencia,Spain 8-)

@broadblues

Thank you very much.

_________________
Cuida tus piedras gordas.

A1200/030 32Mb
A4000D
A1-X1000.

 Status: Offline
Profile     Report this post  
AmiDARK 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 20:40:13
#7 ]
Regular Member
Joined: 28-Mar-2007
Posts: 469
From: South France

Thank you for the answer(s) :)

I will check all this.

Regards,
AmiDARK

 Status: Offline
Profile     Report this post  
Ami603 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 16-Jul-2012 21:45:56
#8 ]
Cult Member
Joined: 7-Mar-2003
Posts: 580
From: Valencia,Spain 8-)

@AmiDARK

As for FileInfoBlock, have a look at IDOS->ExamineObjectTags()

i think it will be more future-proof than FIB stuff.

_________________
Cuida tus piedras gordas.

A1200/030 32Mb
A4000D
A1-X1000.

 Status: Offline
Profile     Report this post  
itix 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 7:23:38
#9 ]
Elite Member
Joined: 22-Dec-2004
Posts: 3398
From: Freedom world

@AmiDARK

It is easy:


struct FileInfoBlock fib;
BPTR lock = Lock(filename, ACCESS_READ);

if (lock)
{
Examine(lock, &fib);
UnLock(lock);
}


That is it. On PowerPC stack is always long word aligned and you are not forced to use AllocDosObject() or AllocMem().

If coding for AmigaOS/68k you must allocate long word aligned FIB.

Last edited by itix on 17-Jul-2012 at 07:24 AM.

_________________
Amiga Developer
Amiga 500, Efika, Mac Mini and PowerBook

 Status: Offline
Profile     Report this post  
OldFart 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 7:51:21
#10 ]
Elite Member
Joined: 12-Sep-2004
Posts: 3066
From: Stad; en d'r is moar ain stad en da's Stad. Makkelk zat!

@AmiDARK

In OS4Depot you might find a tutorial (from me) about some DOS functions, called DosTutorials.lha. Example 2 and 3 make use of the ExamineObjectTags() function. Maybe it is of interest to you.

OldFart

_________________
Life is a waste of time.
Time is a waste of life.
Get wasted all the time
and you'll have the time of your life!

 Status: Offline
Profile     Report this post  
OldFart 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 7:53:24
#11 ]
Elite Member
Joined: 12-Sep-2004
Posts: 3066
From: Stad; en d'r is moar ain stad en da's Stad. Makkelk zat!

@itix

In OS4 the use of Examine() is deprecated in favour of ExamineDosObject().
Quote:
Examine -- Examine a directory or file associated with a lock
( DEPRECATED - use ExamineObject() from V52+ )


OldFart

EDIT: Corrected sloppy spelling as 'deprecated' has an 'e' and not a 'i' in 5th position...

Last edited by OldFart on 17-Jul-2012 at 07:54 AM.

_________________
Life is a waste of time.
Time is a waste of life.
Get wasted all the time
and you'll have the time of your life!

 Status: Offline
Profile     Report this post  
itix 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 9:03:36
#12 ]
Elite Member
Joined: 22-Dec-2004
Posts: 3398
From: Freedom world

@OldFart

In MorphOS Examine() is still valid and there is even Examine64() variant to get more information from a lock.

_________________
Amiga Developer
Amiga 500, Efika, Mac Mini and PowerBook

 Status: Offline
Profile     Report this post  
Xenic 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 14:52:25
#13 ]
Super Member
Joined: 2-Feb-2004
Posts: 1246
From: Pennsylvania, USA

@Ami603
Quote:
if((OutPipe = IDOS->Open("PIPE:CmdOut", MODE_NEWFILE)))

Maybe it's there but I don't see "OutPipe" being closed anywhere in your code before it exits.

_________________
X1000 with 2GB memory & OS4.1FE

 Status: Offline
Profile     Report this post  
Xenic 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 15:06:06
#14 ]
Super Member
Joined: 2-Feb-2004
Posts: 1246
From: Pennsylvania, USA

@AmiDARK
Ami603's IDOS->SystemTags() example looks O.K. except I would use something like:

SYS_Input, Open("nil:", MODE_NEWFILE),

for the Input filehandle. In async mode the i/o filehandles will be closed when the process ends and I don't know if defining SYS_Input as NULL will prevent AmigaDOS from closing the parent process input filehandle. I've never found any specific mention of supplying NULL as a filehandle in the documentation so I play it safe and supply a filehandle to NIL: for async processes.

_________________
X1000 with 2GB memory & OS4.1FE

 Status: Offline
Profile     Report this post  
Hypex 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 15:11:07
#15 ]
Elite Member
Joined: 6-May-2007
Posts: 11329
From: Greensborough, Australia

@itix

The stack may be aligned but using it for system structures is not the proper way of doing it. AllocDosObject() is. Which also avoids relying on the hardware for any such features.

 Status: Offline
Profile     Report this post  
Hypex 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 15:15:40
#16 ]
Elite Member
Joined: 6-May-2007
Posts: 11329
From: Greensborough, Australia

@OldFart

They don't want us using using functions like CreateMsgPort() wither. But I don't see why, it is a clean function. After all, I've seen it approved to use input.device still when commodiies.library should do the job but somehow can't. Using input.device goes back to the real Amiga 1.3 days. So I see no problem using an "old" function that does the job and is future proof.

 Status: Offline
Profile     Report this post  
itix 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 15:27:48
#17 ]
Elite Member
Joined: 22-Dec-2004
Posts: 3398
From: Freedom world

@Hypex

AmigaOS has no restrictions on using stack space to store data (like neither have MorphOS or AROS).

Consider following example:


TEXT buf[500];
struct FileInfoBlock *fib = (APTR)&buf;

stccpy(buf, "PROGDIR:", sizeof(buf));
AddPart(buf, "Image.png", sizeof(buf)); // Buf is passed to dos.library
fh = Open(buf, MODE_OLDFILE); // Again buf is passed to dos.library
ExamineFH(fh, &fib); // Yet again same buf is passed to dos.library
Close(fh);


FileInfoBlock is not a system structure. It is just pointer to a buffer used to retrieve data.

If you still insist FIB must be allocated using AllocDosObject() (why?) you should also use system routines to allocate space for names passed to Lock(), Open() etc.

As you see this idea to use AllocDosObject() to allocate FIB is insane idea. For other structures like ExAllControl it is needed because structure must be initialized properly before passed to dos.library.

Only real reason to use AllocDosObject() is long word alignment requirement in AmigaOS (but not in MorphOS or AROS). In old days it was source of many bugs because developers didnt know about long word alignment restrictions resulting in random behaviour/memory trashing.

CreateMsgPort

Btw following code is sometimes used:


void CreateQPort(struct MsgPort *port)
{
port->mp_Node.ln_Type = NT_MSGPORT;
port->mp_Flags = PA_SIGNAL;
if ((BYTE) (port->mp_SigBit = AllocSignal(-1)) == -1)
{
port->mp_SigBit = SIGB_SINGLE;
SetSignal(0, SIGF_SINGLE);
}
port->mp_SigTask = FindTask(NULL); // SysBase->ThisTask would be faster here
NEWLIST(&port->mp_MsgList);
}

void DeleteQPort(struct MsgPort *port)
{
if (port->mp_SigBit == SIGB_SINGLE)
{
SetSignal(0, SIGF_SINGLE);
}
else
{
FreeSignal(port->mp_SigBit);
}
}


In AmigaOS it is neat because it saves from memory fragmentation and you dont have to test if memory allocation failed.

Last edited by itix on 17-Jul-2012 at 03:35 PM.
Last edited by itix on 17-Jul-2012 at 03:32 PM.
Last edited by itix on 17-Jul-2012 at 03:30 PM.

_________________
Amiga Developer
Amiga 500, Efika, Mac Mini and PowerBook

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 15:32:08
#18 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12931
From: Norway

@Ami603

This line is dangerous


Buffer = Iexec->AllocVec(frld->frld_LineLength,MEMF_ANY)

You should add “+1”, you need space for zero terminated strings, the original line can result in unexpected behavior or a DSI error.


Buffer = Iexec->AllocVec(frld->frld_LineLength+1,MEMF_ANY)

Last edited by NutsAboutAmiga on 17-Jul-2012 at 03:32 PM.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
NutsAboutAmiga 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 15:36:58
#19 ]
Elite Member
Joined: 9-Jun-2004
Posts: 12931
From: Norway

@itix

Quote:

itix wrote:
@OldFart

In MorphOS Examine() is still valid and there is even Examine64() variant to get more information from a lock.


Examine does not report correct file size if file is more then 2Gb or 4gb, don't remember the max size atm.

_________________
http://lifeofliveforit.blogspot.no/
Facebook::LiveForIt Software for AmigaOS

 Status: Offline
Profile     Report this post  
itix 
Re: Dos.library SystemTags & FileInfoBlock
Posted on 17-Jul-2012 15:54:52
#20 ]
Elite Member
Joined: 22-Dec-2004
Posts: 3398
From: Freedom world

@NutsAboutAmiga

Examine64() will report correct size. But he was not asking about file size but file date.

And really, this DOS64 support on Amiga is most of time unused. There are only few applications requiring large file support.

Last edited by itix on 17-Jul-2012 at 03:57 PM.

_________________
Amiga Developer
Amiga 500, Efika, Mac Mini and PowerBook

 Status: Offline
Profile     Report this post  
Goto page ( 1 | 2 | 3 | 4 Next Page )

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle