Hi,
Am I correct in saying that now to get all the file info from a file you should use ExamineObject()?
Cheers,
Coder
ExamineObject()
Re: ExamineObject()
Indeed you are right!Coder wrote:Hi,
Am I correct in saying that now to get all the file info from a file you should use ExamineObject()?
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
- tonyw
- AmigaOS Core Developer
- Posts: 1483
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: ExamineObject()
You'll find it a hell of a lot easier than the old way. Faster, too.
cheers
tony
tony
Re: ExamineObject()
@abalaban/Tony
Thanks. I read the dos library autodoc and did notice some changes including the ExamineObject(). I have not seen any examples around on the net using the ExamineObject().
Cheers,
Coder
Thanks. I read the dos library autodoc and did notice some changes including the ExamineObject(). I have not seen any examples around on the net using the ExamineObject().
Cheers,
Coder
Re: ExamineObject()
Simplified example from my CompareDirs tool :
You have examples of both ExamineObject (to resolve the link) and ExamineDir, ask if you want more. I'll probably create an article in the wiki about this.
Code: Select all
int32 success= FALSE;
APTR context = IDOS->ObtainDirContextTags( EX_StringNameInput, dirname,
EX_DoCurrentDir,TRUE, /* for recursive lock */
EX_DataFields,(EXF_NAME|EXF_LINK|EXF_TYPE|EXF_SIZE|EXF_DATE),
TAG_END);
if (context)
{
struct ExamineData *dat;
while ((dat = IDOS->ExamineDir(context)))
{
if ( EXD_IS_DIRECTORY(dat))
{
IDOS->PrintF("%s is a directory\n", dat->Name);
}
else
{
int64 fileSize = dat->FileSize;
if ( EXD_IS_LINK(dat) )
{ // it's a link try to resolve it
struct ExamineData * linkedobj=
IDOS->ExamineObjectTags(EX_StringNameInput,dat->Link,TAG_END);
if (linkedobj)
{
fileSize = linkedobj->FileSize;
IDOS->PrintF("%s is a link to %s whose size is %lld\n", dat->Name, linkedobj->Name, fileSize);
IDOS->FreeDosObject(DOS_EXAMINEDATA, linkedobj);
linkedobj = NULL;
}
}
else
{
IDOS->PrintF("%s is a file whose size is %lld\n", dat->Name, fileSize);
}
}
}
if ( ERROR_NO_MORE_ENTRIES == IoErr())
{
success = TRUE; /* normal exit */
}
else
{
UI->error( _T(MSG_ERR_EXAMINING_DIR) ); /* failure - why ? */
}
}
else
{
UI->error( _T(MSG_ERR_OBTAINING_DIR_CONTEXT) ); /* failure - why ? */
}
IDOS->ReleaseDirContext(context); /* NULL safe */
Last edited by abalaban on Tue Mar 12, 2013 12:11 pm, edited 1 time in total.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
Re: ExamineObject()
Pretty, pretty please!abalaban wrote:I'll probably create an article in the wiki about this.

X1000|II/G4|440ep|2000/060|2000/040|1000
Re: ExamineObject()
@abalaban
Thanks for the example! That will get me started.
Cheers,
Coder
Thanks for the example! That will get me started.
Cheers,
Coder
- colinw
- AmigaOS Core Developer
- Posts: 218
- Joined: Mon Aug 15, 2011 10:20 am
- Location: Brisbane, QLD. Australia.
Re: ExamineObject()
[...]
int64 fileSize = dat->FileSize;
if ( EXD_IS_LINK(dat) && 0 == fileSize)
{ // it's a link try to resolve it
[...]
Please avoid making assumptions like this, the filesize has no bearing on whether something is
a linked object or not.
Please distribute only example code provided in the latest autodoc file; dos.doc et al.
I believe the latest SDK files will be publicly distributed shortly.
int64 fileSize = dat->FileSize;
if ( EXD_IS_LINK(dat) && 0 == fileSize)
{ // it's a link try to resolve it
[...]
Please avoid making assumptions like this, the filesize has no bearing on whether something is
a linked object or not.
Please distribute only example code provided in the latest autodoc file; dos.doc et al.
I believe the latest SDK files will be publicly distributed shortly.
Re: ExamineObject()
Then you didn't look carefully enough. YAM is using ExamineObject() from the very first day since this function started to exist.Coder wrote:I have not seen any examples around on the net using the ExamineObject().
Last edited by tboeckel on Tue Mar 12, 2013 9:06 am, edited 1 time in total.
Re: ExamineObject()
Yes Colin, you are right, it was a short example I extracted from an existing code and in this code I had to resolve the link only when the fileSize was 0. The fact it has null size does not imply anything on the fact the file is a link or not of course.colinw wrote:[...]
int64 fileSize = dat->FileSize;
if ( EXD_IS_LINK(dat) && 0 == fileSize)
{ // it's a link try to resolve it
[...]
Please avoid making assumptions like this, the filesize has no bearing on whether something is
a linked object or not.
Please distribute only example code provided in the latest autodoc file; dos.doc et al.
I believe the latest SDK files will be publicly distributed shortly.
Source code modified to prevent bad assumptions.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC