本文整理汇总了C++中IoErr函数的典型用法代码示例。如果您正苦于以下问题:C++ IoErr函数的具体用法?C++ IoErr怎么用?C++ IoErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IoErr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AllocMem
struct DosList *MyMakeDosEntry(struct Handler *handler, const TEXT *name, LONG type)
{
struct DosList *entry;
LONG error = 0;
entry = AllocMem(sizeof(struct DosList), MEMF_CLEAR | MEMF_PUBLIC);
if(entry != NULL)
{
if(!MyRenameDosEntry(handler, entry, name))
error = IoErr();
entry->dol_Type = type;
}
else
error = IoErr();
if(error != 0)
{
MyFreeDosEntry(handler, entry);
entry = NULL;
}
SetIoErr(error);
return entry;
}
示例2: main
int main()
{
LONG result = 0;
LONG ioerr = 0;
TEXT buffer[16];
fh = Open("T:a", MODE_NEWFILE);
/* Invalid parameters */
SetIoErr(0);
result = FRead(fh, buffer, 0, 0);
ioerr = IoErr();
TEST((result == 0));
TEST((ioerr == 0));
/* EOF */
SetIoErr(0);
result = FRead(fh, buffer, 1, 1);
ioerr = IoErr();
TEST((result == 0));
TEST((ioerr == 0));
/* BNULL file handle */
SetIoErr(0);
result = FRead(BNULL, buffer, 1, 1);
ioerr = IoErr();
TEST((result == 0));
TEST((ioerr == 0));
cleanup();
return OK;
}
示例3: main
int main(void) {
ARP2_SysCallBase = OpenResource(ARP2_SYSCALL_NAME);
if (ARP2_SysCallBase != NULL) {
LONG fd = arp2sys_open("/etc/passwd", O_RDONLY, 0);
PrintFault(IoErr(), "arp2sys_open");
Printf("Opened file %ld\n", fd);
if (fd != -1) {
char buf[512];
LONG count = arp2sys_read(fd, buf, sizeof (buf) - 1);
buf[511] = 0;
PrintFault(IoErr(), "arp2sys_read");
Printf("Read %ld bytes.\n", count);
PutStr(buf);
PutStr("\n");
}
arp2sys_close(fd);
PrintFault(IoErr(), "arp2sys_close");
Printf("Closed file %ld\n", fd);
}
return 0;
}
示例4: my_rename
/******************************************************************
* my_rename
******************************************************************/
int my_rename (const TCHAR *oldname, const TCHAR *newname) {
LONG res;
char cmd[255];
DebOut("oldname: %s newname %s\n", oldname, newname);
res=Rename(oldname, newname);
if(res==DOSTRUE) {
return 0;
}
/* ugly hack, as windows rename can move over filesystem borders,
* but AROS rename can't. And there seems to be no simple
* API to move a file across filesystem borders...
* So we use the shell and hope for the best..
*/
DebOut("rename failed, try shell copy..\n");
sprintf(cmd, "c:copy from %s to %s MOVE QUIET >NIL:", oldname, newname);
DebOut("execute: %s\n", cmd);
Execute(cmd, NULL, NULL);
if(fsdb_exists(newname)) {
/* there is a file, pray, it is the one we copied ;) */
return 0;
}
SetLastError(IoErr());
DebOut("return -1 (%d)\n", IoErr());
return -1;
}
示例5: main
void main(void)
{
struct AHIAudioModeRequester *req;
BOOL res;
if(AHImp=CreateMsgPort())
if(AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest))) {
AHIio->ahir_Version = 2;
AHIDevice=OpenDevice(AHINAME,AHI_NO_UNIT,(struct IORequest *)AHIio,NULL);
}
if(AHIDevice) {
Printf("Unable to open %s version 2\n",AHINAME);
cleanup(RETURN_FAIL);
}
AHIBase=(struct Library *)AHIio->ahir_Std.io_Device;
req=AHI_AllocAudioRequest(
AHIR_SleepWindow,TRUE,
AHIR_UserData,999,
AHIR_PubScreenName,NULL,
TAG_DONE);
res=AHI_AudioRequest(req,
AHIR_TitleText, "Select a mode or cancel",
AHIR_NegativeText, "Abort",
AHIR_DoMixFreq, TRUE,
AHIR_DoDefaultMode, TRUE,
AHIR_InitialAudioID, 0x20003,
AHIR_InitialMixFreq, 30000,
AHIR_FilterTags, ReqFilterTags,
TAG_DONE);
if(!res)
{
if(IoErr() == ERROR_NO_FREE_STORE)
Printf("AHI ran out of memory!\n");
else if(IoErr() == ERROR_NO_MORE_ENTRIES)
Printf("No available modes!\n");
else
Printf("Requester cancelled!\n");
}
else
Printf("Selected AudioMode: 0x%08lx, %ld Hz\n",req->ahiam_AudioID,req->ahiam_MixFreq);
AHI_FreeAudioRequest(req);
cleanup(RETURN_OK);
}
示例6: readargs_file
static inline SIPTR readargs_file(CONST_STRPTR format, IPTR *args, CONST_STRPTR input, struct RDArgs **retp)
{
SIPTR retval;
struct RDArgs *ret;
BPTR oldin;
BPTR io;
CONST_STRPTR tmpfile = "RAM:readargs.test";
BPTR oldout;
oldout = SelectOutput(Open("NIL:", MODE_NEWFILE));
io = Open(tmpfile, MODE_NEWFILE);
Write(io, input, strlen(input));
Close(io);
io = Open(tmpfile, MODE_OLDFILE);
oldin = Input();
SelectInput(io);
SetIoErr(0);
ret = ReadArgs(format, args, NULL);
*retp = ret;
retval = (ret != NULL) ? RETURN_OK : IoErr();
Close(SelectInput(oldin));
Close(SelectOutput(oldout));
DeleteFile(tmpfile);
return retval;
}
示例7: __seterrno
void __seterrno(void)
{ long amigaerror=IoErr(),*ptr=_errortable,err;
while((err=*ptr++)&&(err!=amigaerror))
++ptr;
errno=*ptr;
}
示例8: L_WB_DeleteDiskObject
// Patched DeleteDiskObject()
BOOL __asm __saveds L_WB_DeleteDiskObject(register __a0 char *name)
{
struct LibData *data;
struct MyLibrary *libbase;
BOOL result;
char *full_name;
// Get library
if (!(libbase=(struct MyLibrary *)FindName(&((struct ExecBase *)*((ULONG *)4))->LibList,"dopus5.library")))
return 0;
// Get data pointer
data=(struct LibData *)libbase->ml_UserData;
// Get full name
full_name=icon_fullname(data,name);
// Write icon
result=L_DeleteIcon(name,libbase);
#define DOSBase (data->dos_base)
// Succeeded?
if ((result || IoErr()==ERROR_OBJECT_NOT_FOUND) && full_name)
icon_notify(data,full_name,INF_FULLNAME,1);
#undef DOSBase
// Free full name buffer
FreeVec(full_name);
return result;
}
示例9: main
int main(int argc, char *argv)
{
struct tracked_resource_kind *port_kind;
struct tracked_pool *main_pool;
struct tracked_resource *my_port_resource;
struct MsgPort *my_port;
make_resource_tracking();
assert(!IoErr());
port_kind = make_resource_kind("message port", (void(*)(void *)) DeletePort);
assert(port_kind != NULL);
main_pool = make_tracked_pool();
assert(main_pool != NULL);
my_port = CreatePort(PORTNAME,0);
if (my_port != NULL) {
my_port_resource = make_tracked_resource(main_pool, (void *) my_port, port_kind);
} else {
printf("cannot create port \"" PORTNAME "\"\n");
}
dispose_tracked_pool(main_pool);
assert(FindPort(PORTNAME) == NULL);
return 0;
}
示例10: my_unlink
/******************************************************************
* my_unlink: delete file
******************************************************************/
int my_unlink (const TCHAR *name) {
BOOL res;
DebOut("name: %s\n", name);
res=DeleteFile(name);
if(res!=0) {
return 0;
}
SetLastError(IoErr());
DebOut("return -1 (%d)\n", IoErr());
return -1;
}
示例11: write_env_string
static int write_env_string(APTR iff,char *str,ULONG id)
{
if (*str && !(IFFWriteChunk(iff,str,id,strlen(str)+1)))
return IoErr();
return 0;
}
示例12: NameOfLock
/* Returns the lock of a name (Allocated with AllocVec()) */
STRPTR NameOfLock( BPTR lock )
{
STRPTR n;
BOOL again;
ULONG bufSize = 127;
if( !lock ) return NULL;
do
{
again = FALSE;
if((n = (STRPTR)AllocVec(bufSize, 0x10000 )))
{
if( NameFromLock( lock, n, bufSize-1 ) == DOSFALSE )
{
if( IoErr() == ERROR_LINE_TOO_LONG )
{
bufSize += 127;
again = TRUE;
}
FreeVec(n);
n = NULL;
}
}
} while(again);
return n;
}
示例13: do_export_sites
static BOOL do_export_sites(struct display_globals *dg,char *path,LONG *diskerr)
{
BPTR cf;
struct site_entry *e;
struct Node *node,*next;
BOOL ok=FALSE;
if ((cf = Open(path, MODE_NEWFILE)))
{
if ((ok=Write(cf,head1,strlen(head1))))
{
node = dg->dg_og->og_SiteList->list.lh_Head;
while ((next = node->ln_Succ))
{
e=(struct site_entry*)((Att_Node *)node)->data;
if (!(ok=write_entry(cf,e)))
break;
node = next;
}
}
Close(cf);
}
if (!ok)
*diskerr=IoErr();
return(ok);
}
示例14: saveFile
void
saveFile(Entries entries, char *filename)
{
BPTR f;
struct IFFHandle *iff = NULL;
f = Open(filename, MODE_NEWFILE);
if (f == NULL) {
myMsg3("couldn't open ", FileName, IoErr());
return;
}
iff = AllocIFF();
if (! iff) {
myMsg1("couldn't alloc iff");
return;
}
iff -> iff_Stream = f;
InitIFFasDOS(iff);
if (OpenIFF(iff, IFFF_WRITE)) {
myMsg1("couldn't OpenIFF(WRITE)");
return;
}
writeDatabaseFile(entries, iff);
CloseIFF(iff);
Close(iff -> iff_Stream);
FreeIFF(iff);
}
示例15: utime
int
utime(const char *name, const struct utimbuf *times)
{
struct DateStamp stamp;
unsigned long days, secs;
time_t time;
if (times == NULL)
DateStamp(&stamp);
else {
/*
* AmigaDOS file date is the modification time
*/
time = times->modtime;
/*
* Convert time (secs since 1.1.1970 GMT) to
* AmigaDOS DateStamp (based on 1.1.1978 local time).
*/
time -= __local_to_GMT; /* GMT to local */
days = (unsigned long)time / (unsigned long)(24*60*60);
secs = (unsigned long)time % (unsigned long)(24*60*60);
stamp.ds_Days = (LONG)days;
stamp.ds_Minute = (LONG)(secs / 60);
stamp.ds_Tick = (LONG)((secs % 60) * TICKS_PER_SECOND);
}
if (!SetFileDate((STRPTR)name, &stamp)) {
set_errno(IoErr());
return -1;
}
return 0;
}