home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pDos / MultiDir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  3.6 KB  |  144 lines

  1.  
  2. /*******************************************************************
  3.  $CRT 02 Mar 1997 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>MultiDir.c<<   02 Mar 1997    17:56:59 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/ex/MultiDir p:pLib/StartCode.o p:/pOS_RKRM/pDos/MultiDir.c p:pLib/StdIO.o -l pOSStub -l pOS
  10.  
  11. /***********************************************************
  12.   pOS programing example - Copyright (C) 1995-97 proDAD
  13.  
  14.   This code was written as an easy to understand example,
  15.   how to program pOS features. It is provided 'as-is',
  16.   without any express or implied warranty.
  17.  
  18.   Permission is hereby granted to use, copy and modify
  19.   this source code for any purpose, without fee, subject
  20.   to the following conditions:
  21.  
  22.     (1) This notice may not be removed or altered from any
  23.         source distribution.
  24.  
  25.     (2) Altered source versions must be plainly marked as
  26.         such, and must not be misrepresented as being
  27.         the original source code.
  28.  
  29.     (3) If only executable code is distributed, then the
  30.         accompanying documentation have to state that
  31.         "this software is based in part on examples of
  32.         the pOS developer packet".
  33.  
  34.     (4) Permission for use of this code is granted only
  35.         if the user accepts full responsibility for any
  36.         undesirable consequences. proDAD accept NO LIABILITY
  37.         for damages of any kind.
  38.  
  39.   ©proDAD
  40. ***********************************************************/
  41.  
  42. /*\
  43. *** Example:
  44. ***
  45. \*/
  46.  
  47.  
  48. #define __COMPUTER_AMIGA 1
  49. #define NOMYDEBUG
  50.  
  51. #include "p:pExec/Types.h"
  52. #include "p:pDOS/ArgTags.h"
  53. #include "p:pDOS/Process.h"
  54. #include "p:pDOS/DosDev.h"
  55. #include "p:proto/pExec2.h"
  56. #include "p:proto/pDOS2.h"
  57.  
  58. #ifdef _____ME_____
  59.   #include "grund/inc_string.h"
  60.   #include "grund/inc_stdio.h"
  61. #else
  62.  #ifdef __cplusplus
  63.  extern "C" {
  64.  #endif
  65.   #include <string.h>
  66.   #include <stdio.h>
  67.  #ifdef __cplusplus
  68.  }
  69.  #endif
  70. #endif
  71.  
  72.  
  73. const CHAR *HelpText=
  74. ""
  75. ;
  76.  
  77. const CHAR *PrgHeader=
  78. "";
  79.  
  80. const CHAR *PrgVerText=
  81. "$VER: 1.0 ("__DATE2__") (Copyright 1997 by proDAD) (Created by Holger Burkarth)";
  82.  
  83.  
  84.  
  85. /*----------------------------------
  86. -----------------------------------*/
  87. #ifdef __cplusplus
  88. extern "C"
  89. #endif
  90.  
  91. VOID main()
  92. {
  93.   struct pOS_DosArgs* Args;
  94.   ULONG Ops[1]={0};
  95.  
  96.   Args=pOS_ReadDosArgs(
  97. // 0
  98. "NAME/A",
  99. Ops,sizeof(Ops)/sizeof(ULONG),
  100.  
  101.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  102.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  103.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  104.     TAG_END);
  105.  
  106.   if(Args) {
  107.     struct pOS_DosDevPathInfo PI={0};
  108.     dosname_t NameBuffer[pOS_DosPathName_MAX];
  109.     dosname_t LkBuffer[pOS_DosPathName_MAX];
  110.  
  111.     PI.dopi_CurrDir = ((struct pOS_Process*)pOS_FindTask(NULL))->pr_CurrentDir;
  112.     PI.dopi_PathName=(dosname_t*)Ops[0];
  113.     PI.dopi_Buffer  =NameBuffer;
  114.     PI.dopi_BufSize =sizeof(NameBuffer);
  115.  
  116.     if( pOS_OpenDosDevice(&PI) ) {
  117.       do {
  118.         if(PI.dopi_ResDir != NULL)
  119.           pOS_NameFromObjectLock(PI.dopi_ResDir,LkBuffer,sizeof(LkBuffer));
  120.         else LkBuffer[0]='\0';
  121.  
  122.         printf(
  123.         "Dos-Device 0x%lx Name=<%s>   [dopi_2thDev=0x%lx]\n"
  124.         "CurrentDir 0x%lx <%s>\n"
  125.         "Path <%s>\n"
  126.            ,PI.dopi_Device,PI.dopi_Device->ddv_Dev.lib_Node.ln_Name,
  127.             PI.dopi_2thDev,PI.dopi_ResDir,LkBuffer,PI.dopi_ResName);
  128. /*\
  129. ***  struct pOS_FileLock *Lk;
  130. ***
  131. ***  Lk=pOS_LockObject(PI.dopi_ResDir,PI.dopi_ResName,...);
  132. \*/
  133.  
  134.       } while( pOS_GetNextDosDevice(&PI) );  /* ... get the next possibility */
  135.       pOS_CloseDosDevice(&PI); /* unlock the work-datas */
  136.     }
  137.     else printf("Unknown path <%s>\n",Ops[0]);
  138.  
  139.     pOS_DeleteDosArgs(Args);
  140.   }
  141. }
  142.  
  143.  
  144.