
  .   .  " OS/2 "                            7



                   


  *   㤠 ४਩;
  *  ⥪饩 ४ਨ;
  * ⮥,뫪  २ 䠩;
  *  䠩;
  * 宦   ਡ;
  * 宦   ᭮ 䠩.



   讥 ⢮ API 㭪権 ᯥ稢 ࠧࠧ  ਠ
ࠡ  䠩 ⥬ OS/2.   㭪樨   㯯.
   㭪樨  ࢮ  㯯  ᬠਢ  䠩  譥 ஢:
ࠡ  ४ﬨ  㫨 楫묨 䠩.  㭪樨 ன
㯯 ,     ࠧ 롮ન  ᮤন 
䠩.  ⮩      ᬮਬ  㭪樨 -  㯯. 8
墠뢠   㯯,   9 㦤  ᯮ짮 䠩 
筮 ०.

   C 䠩  OS/2,  魮, ᮢ  ன 䠩
  MS-DOS.M  ࠧ  OS/2    䠩  API  㭪権  ᮢ   
MS-DOS,, ਬ, INT21 맮,᪮ 楫  㭪権,
 ⠭,த⢥., ࠧ  䠩 㭪権
  OS\2    MS-DOS.㭪樨  API   ᯮ짮  筮
०,          ᫮묨,祬 ᮮ⢥騥 㭪樨
MS-DOS.,   API   㭪樨   ࠧࠡ⠭   ᯥ樠쭮    
ᯥ祭 筮 ०.  ࢠ  ⮩   饭
ࠧ   㭪 㦨騬  . ன     㢨 
㫨஢  䠩    ﬨ:    ᪠,뫠   
㭨⮦.

                   㫨஢ ࠧ.

   C ⢮ 稭   뫮  ⥫쭮 㫨-
஢ ४ﬨ   ᮤঠ ணࠬ.ਬ,
⠫樨 ⥫쭮 ᮧ  ४ਨ,ᮤঠ饩 ᯮ-
 䠩.   祭  㯠   䠩, ॡ
   ⥪   ४,ᮤঠ   ।    䠩.
ࢨ᭮ ணࠬ ॡ ᪮஢ ॢ ४਩  
  ᪥  㣮,    ᪠  㣮.    ⮩ 
 ᬮਬ ࠡ API 㭪権,  ᯥ稢.

                   C  㭨⮦ ४਩.

   ᬮਬ    ணࠬ,   ᮧ ४-
ਨ,    㭨⮦  .  ணࠬ 믮  
 DOS MKDIR  RMDIR.  eࢠ ணࠬ:

     /* mkdir2.c */
     /* ᮧ ४ਨ */
     /*   ⥪饩 ४ਨ  㪠  */
     #definr INCL DOS
     #include <os2.h>
     main(argc,argv)
     int argc;
     char *argv[];
        {
               unsigned rc;

               if(argc!=2)
                  { printf(" Syntax mkdir2 dirname"); exit(1); }
               if(rc=DosMkdir(argv[1],OL))  {
                 if(rc==3)
                   printf("path not found");
                 else if(rc==5)
                   printf("Can't make directory");
                 else
                   printf("DosMkdir error=&u",rc);
               exit(1);
            }
            exit(0):
          }


    ணࠬ ᯮ  㬥  ப   祭
 , 㭪 API DosMkdir() ᮧ  ४.

   Ŀ
                  DosMkdir()-ᮧ  ४ਨ.           
    DosMkdir(Pathname,Reserved);                                  
    char far *Pathname; /*ASCIIZ     ४ਨ */ 
    unsigned long Reserved; /* १ࢨ஢,  0 */  
   
  ⮩ 㭪樨 室 ᥣ  ࠬ:   ४-
ਨ.ன   ࠬ,    ᫮,१ࢨ஢       
७ OS\2,      樠஢  㫥.ࢨ஢
  ᫮  饩   ⮩     API  㭪権.    
ᮧ    ४਩    ⥪饩    ४ਨ,室  -
     ப:

     >mkdir2 newdir

    ᮧ ४ਨ  ४ਨ,⫨筮  ⥪饩,-
    :

    C>mkdir2 \letters\xyzcorp\newdir

         㪢 ࠩ஢(     Z, 묨
᫥  稥)    ᮧ  ४਩    㣨  ࠩ.
   ணࠬ   ⠥   ஡   ᮮ饭         
訡,       ⮩  㭪樨.      ⪥   ᮧ
४ਨ    饬  ᪥   (ਬ G)       
 饣 ,뤠 ᮮ饭 "  ", "
ᮧ ४".  C ணࠬ 㭨⮦ ४. 
⥪:

     /* rmdir2.c */
     /* 㭨⮦ ४ਨ */
     #define INCL_DOS
     #include <os2.h>

     main(argc,argv)
     int argc;
     char *argv[];
     {
         unsigned rc;

         if( argc !=2 )
            { printf("Syntax: rmdir2 dirname"); exist(1); }
         if( rc==DosRmdir( argv[1],Ol ) ) {
            if( rc==3 )
              printf("Directory not found");
            else if( rc==5 )
              printf("Can,t remjve directory ");
            else
              printf("DosRmdir error=&u",rc);
            exist(1);
            }
         exist(0);
      }

     ணࠬ  頥    mkdir.c.  ᯮ   㭪樥
DosRmdir    㭨⮦  ४ਨ,ᠭ 㬥⠬ 
ப.

   Ŀ
                  DosRmdir-४ਨ.                           
    DosRmdir(Pathname,Reserved);                                 
    char far *Pathname; /*ASCIIZ      ४ਨ */
    unsigned long Reserved; /* १ࢨ஢,  0 */ 
   
     㭪樨  ॡ  ⮫쪮      ४ਨ   
㭨⮦.  ⮣,⮡  ᯮ짮    DOS  RMDIR 
㭨⮦ 室,⮡ 㭨⮦ ४ 뫠  ⮩.᫨
  ,  ᮮ饭  訡:" 㭨⮦
४".᫨      ࠩ               ᠭ  
묨,ணࠬ ⠥:"४  ".

                   騩 ࠢ  ४.

   楯  "⥪饣   ࠩ"     "⥪饩  ४ਨ"   
 ⫨  饭 ० OS\2, ⮣,   
 MS-DOS. MS-DOS ⥪騩 ࠩ  ४ system-wide states.᫨
ਪ ணࠬ   ⥪騩  ࠩ   ४, 
ਪ  ணࠬ,ᮤঠ騥    樮  ⥬,믮
    ⮬  ࠩ    ४ਨ,  訫  ਪ
 ணࠬ.    㣮  ஭,   OS\2  ⥪  ४    
   묨      ⤥  ᮢ  ( ६ 襭
)  ⤥  ᥠᮢ.    ᪠  ४ਨ  
६  ᥠ      ⥪騩    ४  㣨
ᥠ.,᫨      ⥪騩     ४,
      ⠭    former  values         
襭.㣨  ᫮,ਬ  MD.EXE     믮   
ᥠ          ᪠    ४ਨ,  ᫨    ਪ
ணࠬ    .

                    ⥪饩 ४ਨ.

   騩 ਬ  , ਪ  ணࠬ   
⥪  ४.-,       ⥪饣  ᪠   
४,    ⠥    .⥬,   ᯥ䨪
᪠       ४ਨ           ப,        ,
⢥ত, ⠥   ᪠  ४ਨ.

     /* chdir2.c */
     /*  ⥪饩 ४ਨ (⮫쪮    */
     #define INCL_DOS
     #include <os2.c>
     # define BUFF_LEN 80            /* ࠧ   */

     main(argc,argv)
     int argc;
     char *argv[];
     {
         unsignet drive;                 /*  ࠩ (=1,
                                                          ..) */
         unsignet long map;              /*  ࠩ஢ (
                                                  ᯮ) */
         unsignet bufflen=BUFF_LEN;      /* ࠧ   */
         char pathbuff[BUFF_LEN];        /*   */
         unsignet rc;                    /*   */

         if( argc!=2 )
           { printf("Syntax: chdir2 pathname");exit(1);}
         if( rc=DosQCurDisk(&drive,&map) )
           { printf("DosQCurDisk error=&u",rc);exit(1);}
                                         /*  ⥪饩 ४-
                                                          ਨ */
         if( rc=DosQCurDir(drive,pathbuff,&bufflen ) )
           { printf("DosQCurDir error=&u",rc);exit(1);}
         printf("Old directory=&c:\\&s\n",drive+('A'-1),pathbuff);
         if( argv[1][1]=':')        {    /*  砥 ᯥ䨪樨
                                                       ࠩ */
             drive=toupper( argv[1][0] );/* 祭 㪢 */
             drive-='A'-1 ;              /* ८ࠧ 
                                                           */
             if( rc=DosSelectDisk( drive ) ) /*  ࠩ */
                 if( rc==15 )
                     { printf("Invalid drive");exit(1); }
                 else
                     { "DosSelectDisk error=&u",rc);exit(1): }
     }
                                         /*  ४ਨ */
     if( DosChDir( argv[1],OL) )
         if( rc==3 )
             { printf("Invalid directory path");exit(1);}
         else
             { printf("DosChDir error=&u",rc);exit(1); }

                                         /*   ४ਨ */
     if( rc=DosQCurDir( drive,pathbuff,&bufflen ) )
         { printf("DosQCurDir error=&u,rc);exit(1); }
     printf("New directory =&c:\\&s\n",drive+64,pathbuff);
     exit(0);
     }


    ணࠬ ᮤন 4   API 㭪樨. ⮣,⮡  뢥
⥪饥      室   㧭  ⥪騩  ࠩ   ᪠,
ண  頥 ࢠ API 㭪 DosQCurDisk().

  Ŀ
                  DosQCurDisk()- ⥪饣 ࠩ ᪠.    
    DosQCurDisk(APath,AMap)                                       
    unsigned far *APath;    /*    ࠩ */      
    unsigned long far *AMap; /*   ࠩ */       
  

   "Q"  DosQCurDisk() 砥 "".   ᥬ⢠ 㭪権
,ᯮ  祭 ࠧ த ଠ樨   䠩
 䠩  ⥬. 쭥襬   ⮫   ⠪  㭪ﬨ.
    ଠ,頥    DosQCurDisk()    ⮨         
⥩:  ⥪饣  ࠩ   (ࠩ    ᢠ   
1,ࠩ  ᢠ  2, ..)   ࠩ.  
   ᫮,஥   뢠,      ࠩ      
⥬:0-    ᮮ⢥  ࠩ  ,1-    ⢥
ࠩ , ..,  25  ࠩ Z).᫨   祭
1,  ᮮ⢥騩  ࠩ      ⥬.    
 ଠ樥   ਪ  ணࠬ,ᬮ   , 
ਬ   ᯮ .    ࠩ  ᯮ    室
ࠬ      㣮   㭪樨   ,DosQCurDir().   㭪
頥  ⥪饩 ४ਨ.

  Ŀ
                DosQCurDir()- ⥪饩 ४ਨ.        
    DosQCurDir(Drive,APath,ALength)                           
    unsigned Drive;          /*   ࠩ */            
    char far *APath;         /*     */   
    unsigned far *ALength;   /*     */  
  


    㭪 ॡ ⠪   ,   室
  .,ᮧ   DosQCurDir(),ᮤন     孨   
ࠪ⨪.        砥  ᯥ䨪   ࠩ,砫쭮
⭮  ᮩ  ,  ⠪  ணࠬ,뤠   ଠ 
뢮    .   ⮣ ⮡  㦨,  짮⥫
         ࠩ  ᪠,   ணࠬ ᬠਢ
ன ࠬ  ப:argv[1][1].᫨  ࠬ 窠 
⮩,  ।騩    ᨬ  ⠥  㪢 ࠩ.
⮣,⮡ ८ࠧ 祭 ࠬ ''    1 ('B'   2 
..),⢮     'A'-1     (64)     ⠥         祭
ࠬ.     ࠩ ᯮ    㬥 㭪樨
DosSelectDisk.

   Ŀ
                  DosSelectDisk()-롮 ⥪饣 ࠩ ᪠.   
     DosSelectDisk(Drive);                                         
     unsigned Drive;          /*  ࠩ (1=A,2=B, ..) */
   
     ⮣,⮡      ᯥ䨪樨,  㭪 뢠
⥪騩 ࠩ.  ⬥⨫  ࠭, 롮 ⢨⥫  ⮫쪮
  ६  믮  ,맢  㭪樥:  ⮫쪮  
   稢,⥪騩   ࠩ    頥       ᢮
ࢮ砫쭮   祭.᫨      ᯮ       
ࠩ,  ணࠬ  ⠥  ᮮ饭:"   ࠩ".-
  ⮩  ணࠬ    㭪  DosChdir(), 
४ਨ.

   Ŀ
                DosChdir-롮 ⥪饩 ४ਨ.                
     DosChdir(Path,Reserved);                                     
     char far *Path;          /*   ४ਨ */          
     unsigned long Reserved;  /* १ࢨ஢;  0 */ 
   

  ⢥ ଠ樥,ॡ㥬 ⮩ 㭪樥,  
 ४ਨ.᫨   ᯮ  饭   ,㭪
뤠  ᮮ饭:"⨬     ४ਨ".
   ᫥ ⮣,   ⥪   ४   ࠭,ணࠬ   -
     ,ᯮ㥬 DosChDir().  뢠,  
ணࠬ ࠡ祩    ४.   砥   ஬
᪠,᫥   롮    ࠭    ⮫쪮         祭
⥫쭮   ⥪饣 ;    蠥,⥪饩
४ਥ  ⠭    ४,   뫠    ࢮ砫쭮.
  ਢ   ਬ       ணࠬ.      
ਣ襭 OS\2,஥ 砥  ⥪饩 ४ਨ.

     [C:\SAMPLES\WED]chdir2 b:\notes\thurs
      Old directory = C:\SAMPLES\WED
      New directory = B:\NOTES\THURS
      [C:\SAMPLES\WED]

   ਣ襭,⠭   OS\2    ᫥    襭    ணࠬ
뢠,  ࠩ  ४ 㫨  ᢮  ࢮ砫
祭.


                   㫨஢ 䠩.

     㭪権,  㫨 ४ﬨ, ᭥  
㭪権,     㦨  䠩.   ᬮਬ  㭪樨    
㭨⮦,뫪  ᪠ 䠩.


                   ⮦ 䠩.

     ⪠  ணࠬ  㭨⮦  䠩,⠭  ⢥
㬥⮢     ப.     ⠭      
䠩(᫨ 䠩 室  ⥪饩 ४ਨ),  .
 ⠪ 㪠 ᯥ䨪 ࠩ.

     /* delete.c */
     /*  DosDelete() */
     #define INCL_DOS
     #include <os2.h>

     main(argc,argv)
     int argc;
     char *argv[];
     { unsigned rc;

       if( argc!=2 )
         { printf("Syntax: delete filename"); exit(1); }
       if( rc==DosDelete( argv[1], OL ) ) {
           if( rc==2 )
               printf("File not found ");
           else if( rc==32 )
               printf("Sharing violation ");
           else
               printf("DosDelete error=&u",rc);
           exit(1);
      }
      printf("&s deleted",argv[1]);
      exit(0);
      }

     ணࠬ  ᯮ  API  㭪  DosDelete().⮩  㭪樨
 ॡ  ⮫쪮  ଠ       㭪樨, 㤥
 㭨⮦.

   Ŀ
                  DosDelete()- 㭨⮦ 䠩.                 
    DosDelete(FileName,Reserved);                                 
    char far *FileName;       /* ASCIIZ ப   䠩 */ 
    unsigned long Reserved;   /* १ࢨ஢;  0 */ 
   
   ᫨  ணࠬ   ᯮ짮     㭨⮦   饣
䠩, 㤥 ⠭  ᮮ饭:"  ".᫨   ᤥ
  㭨⮦  䠩,ᯮ㥬     㣮   ,
ᮮ饭:"襭  ᮢ᭮   ᯮ짮".   ,᫨
,ਬ, ⠥ 㭨⮦ ⥬ 䠩 SWAPPER.DAT.


                  뫪 䠩.

    ਬ 뫠 䠩    ४ਨ   .
䠩,      뫠,  ४ਨ,     
뫠,  㬥  ப.

     /* move.c */
     /* 뫪 䠩  ४ਨ */
     #include <doscalls.h>
     #includ<string.h>

     main(argc,argv)
     int argc;
     char *argv[];
     {
       int rc;
       char *LastSlash;
       char FileName{80];      /*  䠩   */
       char OldName[80];       /* ஥   DosMove() */
       char NewName[80];       /*    DosMove() */

       if( argc!=3 )
         { printf("Syntax:C>move filename directory");
      exit(1); }
         strpy( OldName,argv[1] );
         strpy( NewName,argv[2] );

                                /* 뤥  䠩  ண
                                                               */
         if(LastSlash=strrchr(OldName,'\\') )  /* ᫨   */
            strcpy( FileName,LastSlash+1 );    /* ᫥   */
          else                                 /* ᫨  ᮩ
                                                              */
            strcpy( FileName,OldName );        /* ⮫쪮  */
                    /* ਡ塞     砥
                                                      室 */
          if( NewName[strlen(NewName)-1]!='\\' )
      strcat( NewName,"\\" );

                              /* ਡ塞  䠩  
                                                        */
      strcat( NewName,FileName );

                              /* 뫠 䠩 */
      printf("Moving &s to &s \n",OldName,NewName );
      if( rc==DOSMOVE( OldName,NewName,Ol ) )
           if( rc==2 )
              { printf("No suth file");exit(1); }
           else if( rc==3 )
              { printf("No suth directory");exit(1); }
           else if( rc==5 )
               {printf("Can't move to that directory");exit(1);}
           else
               {printf("DosMove error=&d",rc); exit(1);}
      exit(0);
      }

     ணࠬ  ᯮ  㭪  DosMove().DosMove()  ॡ 2
㬥.     㭪樨, 㤥 뫠.
   ,᫨  䠩 室  㣮  ४ਨ.ன
ࠬ   -                  䠩,    㤥
⠭.⮢砥   ᫥⥫쭮 ४਩,⠪   
 䠩.   設⢮  짮⥫           
䠩(..        ),     ४,
  䠩  㤥  ६饭.   ,  뫪 䠩 NOTE.TXT 
४ \LETTERS\NOV   :

     >move note.txt\letters\nov

 :

     C>move note.txt \letters\nov\note.txt

      , ⢥  ண ࠬ  DosMove() ॡ  
䠩       ४ਨ,  ⮬ ணࠬ  
।  䠩, ᬠਢ  㬥   ப,
⮣            ४ਨ   ன
㬥    ப.   ⠪  ॡ   ⠢
  ,᫨ 짮⥫  ⠫     
४ਨ.㭮 7-1 뢠,  룫廊.

 Ŀ
                                                                  
                                                                  
                               >MOVE \WPOC\NOTE.TXT\LETTERS\DEC  
                                                         
                                                               
                                                               
    1)᫥ ᬠਢ ⭠                       
                           
                                                                
    2) 䠩                
                                                                 
    3)᫨  ⭮ ᮩ , 
        ਡ   ४ਨĿ           
                                                                 
                                          \LETTERS\DEC\NOTE.TXT   
                                                           
    4)ਡ        
                                                                  
                                                                  
 
 . 7-1.


     믮   樨  ⪨,ணࠬ   뢮     
㬥,   DosMove(). ,᫨ 䠩 맢
SMITH.INV   㤥    ᫠       ⥪饩      ४ਨ,\CALCS,
,\INVOICES\NOV:

     [C:\CALCS]move smith.inv\invoices\nov
     Moving smith.inv\invoices\nov\smith.inv

            ,䠩 ᫠   ४.

     [C:\CALCS]move \invoies\nov\smith.inv\calcs
     Moving \invoies\nov\smith.inv\calcs\smith.inv

    ⢥  ᮮ饭   ⮬ ணࠬ     
   䠩  㬥 ன  ப.㬥  ࢮ
  ப      ⮫쪮     䠩   
   .ணࠬ   蠥,           ਠ⮢
ᯮ  ᮮ⢥⢥ ⮬ ᮧ  䠩. 䠩  ⮬
砥 ਡ  㬥  ன  ப   ᮧ
ண ࠬ  DosMove().

   Ŀ
                  DosMove()-뫪 䠩.                       
    DosMove(OldName,NewName);                                       
    char far *OldName;        /* ASCIIIZ   䠩-ਣ*
    char far *NewName;        /* ASCIIIZ             
                                                     ⮯*
    unsigned long Reserved;  /* १ࢨ஢;  0 */    
   
   ᫨ 짮⥫ ⠥ ᫠ 䠩,   ,
ணࠬ  ⠥  ᮮ饭:"  ⠪ 䠩".⪠ ᫠
 䠩      ४  맮  ᮮ饭:"
⠪  ४ਨ".饭  "  ᫠       ४"
 १⮬ ⪨  ᫠ 䠩   ४, 㦥
ᮤন 䠩  ⠪ .


                   २ 䠩.

      ,   ࠬ   move.c,     
२뢠 䠩  ६ 뫪.,    
DosMove().        ணࠬ, २뢠
䠩.짮⥫ 뢠  ணࠬ    ,   
㪠뢠  㬥  ப

     /* rename2.c */
     /* २ 䠩 */
     #define INCL_DOS
     #include <os2.h>

     main(argc,argv)
     int argc;
     char *argv[];
     {
         int rc;

         if( argc!=3 )
            { printf( "Syntax: rename2 oldname newname");exit(1); }
                                /* ७ 䠩    */
         if( rc=DosMove( argv[1],argv[2],OL ) )
           if( rc==2 )
              { printf("No suth file");exit(1); }
           else if( rc==3 )
              { printf("No suth pathname");exit(1); }
           else if( rc==5 )
              { printf("New name isinvalid");exit(1); }
           else
              { printf("DosMove error=&d",rc);exit(1);}
         exit(0);
       }


   B 裡  ⥬, ।, 짮⥫ 㪠   䠩
  㬥⮢,८ࠧ    ॡ,  
   祭  㭪樥  DosMove().   ⥪饩 ४ਨ 
  २ ᫥騬 ࠧ:

     C>rename2 joe.let harry.let

         ६饭      ४   २
६:

     C>rename2 joe.let\letters\nov\harry.let
     C>rename2 \letters\nov\harry.let \archive\harry.let

   ᫨ ணࠬ  㤠   ஥ , 뤠:"  ⠪
䠩".  ᫨      ᫥  㪠    䠩
, ⠥:  " ⠪  ", ᫨ 䠩     㦥
,:"୮  ".  뫮   ꥤ
	 ணࠬ  move.c    rename.c    樨  㭪樮
⥩  COPY   襭.


                    䠩.

    API  OS/2  ᮤন      㭪樨    ᪠  䠩  
ᯥ᪨   ᠭ.   ᠭ           蠡
,      ᯮ짮    ᪠ 㣨 䠩 
ᮢ騬 ᠭﬨ.


                     䠩.

   ࢠ           㭪権   -    DosFindFirst(),    
 䠩,⨢訩    ᯥ䨪樨. 㭪,DosFindNext(),
   ᫥⥫쭮   䠩,⨢訥     ᯥ䨪樨.
,DosFindClose() ᯮ   ᪠  蠥.
     襬  ࢮ   ਬ  ᯮ  ⮫쪮   DosFindFirst() 
DosFindClose(). ணࠬ    ᯥ䨪 䠩    㬥
 ப,   뢮         ଠ 
ࢮ ⨢襬 䠩  ⮩ ᯥ䨪樥  ⥪饩 ४ਨ.

     /* findfirst */
     /*  DosFindFirst() */
     #define INCL_DOS
     #include <os2.h>
     #include <string.h>           /*  strcpy() */
     #define ATTTR 0x0037          /*   䠩 
                                                          ⨯ */
     #define LENGHT sizeof(buff)   /* ࠧ  १ */
     #define READ_ONLY 0x0001      /* 祭 ᫮  ਡ */
     #define HIGGEN 0x0002
     #define SYSTEM 0x0004
     #define DIRECT 0x0010
     #define ARCHIVE 0x0020
     main(argc,argv)
     int argc;
     char *argv[];
     {
         char pathname[80];              /*   
                                                              */
         unsigned short handle=0xFFFF;   /* ࠧ饭  */
         struct _FILTFINDBUF buff;       /* ।  os2def.h */
         unsigned count=1;               /*  室 稭 */
         unsigned rc;                    /*  १ */

         if( argc!=2 )
             { printf("Syntax:findfirst pathname ");exit(1); }
         strcpy (pathname,argv[1] );

         if( rc=DosFindFirst( pathname,&handl,ATTR,&buff,LENGHT,
                                                        &count,OL ) )
           if( rc==18 )
              { printf("No suth file");exit(1); }
         else
              { printf("DosFindFirst error=&u",rc); exit(1); }
         printf("Name = &s\n",buff.achname );
         printf("Size = &u\n",buff.cbFile );
         if( buff.attrFile & READ_ONLY ) printf("READ_ONLY\n");
         if( buff.attrFile & HIDDEN) printf("Hidden\n");
         if( buff.attrFile & SYYTEM) printf("System\n");
         if( buff.attrFile & DIRECT) printf("Directory\n");
         if( buff.attrFile & ARCHIVE) printf("Archive\n");
         DosFindClose( handle );
         exit(0);
    }



   ࠬ ⠥   䠩, ࠧ,ࠧ ਡ  (⮫쪮
   ⥭,,⥬,४,娢),    
 .   ਬ,᫨  䠩   ७    ⥪饩
४ਨ   apple.exe, ᫥  ⢨   ணࠬ 
㢨:

     C>findfirs*.exe
     Name = APPL.EXE
     Size = 12084
     Archive

   娢      ⠭,   䠩      ᮧ    
஢,   ⠪ ணࠬ  BACKUP  XCOPY ( 樥
 /m),     ।⥫쭮     "娢"      ⮣
䠩.訬                     "    ६
	 娢஢".  ᫨   findfirs.c ᠭ ஥
ᮮ⢥ ४ਨ,  뢥:

    C>findfirs \os*
    Name = OS2
    Size = 0
    Directory


     ⮣,  ⮡  ᬮ  䠩   㣨 ਡ⠬, 
ᯮ짮 ᯥ䨪, ᮮ⢥ ⥬ 䠩:

    C>findfirs \ibm*.*
    Name = IBMBIO.COM
    Size = 16369
    Read-only
    Higgen
    System

      ଠ 頥 㭪 DosFindFirst().

   Ŀ
                  DosFindFirst()- ࢮ 䠩               
                  ᮮ⢥饩 ᯥ䨪樥.                    
   DosFindFirst(Name,AHandle,Attr,ABuff,Lenght,ACount,Res );        
   char far *Name;                 /* ASCIIZ   */          
   unsigned short far *AHandle;    /*   ᪮           
                                               */          
   unsigned Attr;                  /* ਡ ᪠ */            
   struct _FILEFINDBUF far *ABuff; /*  १ */           
   unsigned Lenght;                /*   १ */   
   unsigned far *ACount;           /*  宫 稭       
                                                          count*/   
   unsigned long Res;              /* १ࢨ஢;        
                                                         0 */   
   

   ᬮਬ 㬥 ⮩ 㭪樨.
           ⮣,   饬  ଥ ଠ쭮
ASCIIZ  ப.㭪  頥  ,  ᯮ  
ᯥ᪮ ᪮  ⥫쭮.   ᯮ 
㬥  㭪権  DosFindNext()   DosFindClose(),।뢠騩 ᥬ
६ 㭪   ᪮ ⥫쭮.    
⥬  ६  ᪮쪨  ᪮  ᠬ.    ६
᭮  ᯮ    ⮫쪮    ।  ᭮  㭪- 樨 
ਪ ணࠬ,  ⠪   ᯥ祭 ଠ樨  ਪ
ணࠬ  㭪樨.  ᫨  ਪ  ணࠬ  ⠭   
६  -1 (0FFFF),⥬ 㧭 । 祭  ᭮,
஥      -1.      ᯮ짮  祭   1,᭮
 ⠭⭮,   筮 㯭.砥,᫨   ᢮
ணࠬ      ᭮,    祭 -1.
᫨ 祭 ᭮ 饭 맮 DosFindFirst()  ᯮ
 ࠧ 㣨 맮 ⮩ 㭪樨,    ।騬 ᮬ
᪠ 뢠,  ⠭   .    ਡ 
㭪樨,  ᥬ⢠ 䠩    .   ᯮ  
  ।⠢ ਡ⮢,   㭪 7-2:


Ŀ
                                                                   
                                                                   
               ćĿ                      
                                                                 
 Ŀ                                    
 Ŀ..Ŀ 
                                                       
  15    14      7    6    5    4    3    2    1    0   
                                                       
 .. 
                                                              
       ARCHIVE                              
       SUB-DIRECTORY                         
       SYSTEM FILE              
       HIDDEN FILE        
       READ-ONLY FILE   
                                                                   

 . 7-2.  ਡ⮢.

   ᫨          ⠭ 㫨,  믮 
⮫쪮   ଠ 䠩.᫨       ⠭,
        ᮮ饭  ⨯  䠩,⠪      
ଠ.
     १       ⨯   _FILEFINDBUF.
   ।    os2def.h. ଠ쭮   ⨯   
 :

     struct _FILEFINDBUF {
         struct _FDATE  fdateCreation;
         struct _FDATE  ftimeCreation;
         struct _FDATE  fdateLastAccess;
         struct _FDATE  ftimeLastAccess;
         struct _FDATE  fdateLastWrite;
         struct _FDATE  fadteLastWrite;
         unsigned long cbFile;           /* 뤥 ࠧ */
         unsigned long cbFileAlloc;      /* 䠪᪨ ࠧ */
         unsigned      attrFile;         /* ਡ */
         unsigned char cchName;          /*   䠩 */
         char          achName[13];      /*  䠩 */
                         }


     FDATE    TIME   ᯮ         ࠧ饭
塞 稭,    ਬ:


         struct _FTIME  {
                 unsigned twosercs : 5; /* ᥪ㭤    */
                 unsigned minutes  : 6;
                 unsigned hours    : 7;
                        };
         struct _FDATE  {
                 unsigned day      : 5;
                 unsigned month    : 4;
                 unsigned          : 7;  /* 1980 ᮮ⢥ 0 */
                        };


   DosFindFirst()  頥  ଠ    뢠  ணࠬ  
   _FILEFINDBUF.  4  童    (६     
᫥ 饭  ᮧ)    䠩 ⥬ OS/2
  ᥣ  ࠢ  0.    ६  ᯮ;  ᥣ    
㪢.  ࠧ஬  䠩    ࠧ  䠩    , 
ࠧ஬ । - ⢮ ,।  䠩.
ਡ    ⠪  ଠ      ਡ,ᠭ   
᪠.   ⮬    ப     ப ᫥
 ,  ।⠢ ᮡ   䠩,饭
㭪樥.      १    㪠  뢠饩
   ணࠬ. ,  ,ᮤঠ ଠ   祬
  䠩.   ࠧ, 稭   ࠧ஬ 
  ᮢ㯭    ࠧ஢,᫨     ᮤন ଠ
  祬        䠩.         ஬   室
   ,  ॡ  .   ᪨   頥
  ९뢠     祭.᪨  ,   頥
䠩,      ⢥,    ⢥饣 ,
,騩 訬.᫨   㢨 ६ ⮫쪮
  䠩,   ॡ  ⠭ 祭  1.   १ࢨ஢
   ६    0.  ᫨  DosFindFirst()     
 䠩  ᮢ饩       ᯥ䨪樥, 頥
訡 18 - NO MORE FILES.


                   宦 㯯 䠩.
   ।   ணࠬ   﫠   짮⥫       
 䠩,ᮢ騩    ᯥ᪨  ᠭ.筮,, ⨬
  㯯  䠩,        .ਬ,  ⮣  
㥬  DOS DIR:


     C>dir*.c


    ⨬ ᤥ   ᬮ  䠩   ७ .C.
       ࠧ    ᬮਬ    ਠ  ணࠬ ᪠
䠩.     ਠ      ,  뢠   
 ᯮ 㭪樨.ன  ᮢ襭.   ⪨ ਠ:

     /* findmany.c */
     /* c᮪ 䠩  ᮮ⢥饩 ᯥ䨪樨 */
     #define INCL_DOS
     #include <os2.h>
     #define LEN sizeof(buff)
     #define PATH_LEN 80
     #define ATTR 0x0000
     main(argc,argv)
     int argc;
     char *argv[];
     {   char path[PATH_LEN]             /*     */
         struct _FILEFINDBUF  buff;      /* ।  os2def.h */
         unsigned short handle=0xFFFF;   /* c  ⮣ 祭 */
         unsigned count=1;
         int rc;                         /*   */

         if( argc!=2 )
             { printf("Syntax:findmany pathname ");exit(1); }

                                /*  ࢮ 室 稭 */
         DosFindFirst( argv[1],&handle,ATTR,&buff,LEN,&count,OL);
         printf("&-14s\n",buff.achName );

     while (TRUE ) {           /*  㣨 室 稭 */
            rc=DosFindNext( handle,buff,LEN,&count);
            if( rc==18) {
                DosFindClose( handle );
                exit(0);
                        }
                        printf("&-14s\n",buff.achName );
            }
      }




    ணࠬ  砥 ᯥ䨪  䠩    ப 
ᯮ       ⢥  㬥     DosFindFirst(),
室    findfirst.c.   ,⮣    室    横,
ᮤন 㭪 DosFindNext().

   Ŀ
                  DosFindNext()- ᫥饣 䠩            
                  ᮮ⢥饩 ᯥ䨪樥.                  
    DosFindNext(Handle,Abuff,Lenght,Acount )                       
    unsigned short Handle;           /*   */         
    struct _FILEFINDBUF far *ABuff;  /*  १ */        
    unsigned Lenght;                 /*   १ */
    unsigned far *aCount;            /*  室 稭    
                                                           count */
   

       㭪    ᯮ    4    ࠬ.᭮     
祭,祭          DosFindFirst().⠢訥     ࠬ
ᯮ   DosFindFirst().    १⮢ ⠪
      DosFindFirst(),     ⮣ ,
뢠 ஢  ᬠਢ    頥  祭
祭.
    ࠧ     㭪 뢠,  頥 ᫥騩
   ᯨ᪠   䠩,ᮮ⢥    ᯥ䨪樨.
ࠧ  , ⠪     DosFindFirst().
    DosFindNext()        䠩 ᮮ⢥
ᯥ䨪樨,    頥  訡  18.  ।뢠 ணࠬ
믮 㭪 DosFindClose()  .
   DosFindClose()   ४頥           DosFindFirst()    
DosFindNext()         ᪠,ॠ   ᭮,祭  
DosFindFirsn().  㭪  ᥣ  㤥  믮    襭
 ᪠.

    Ŀ
                  DosFindClose()-⨥ ᪠ ᭮.   
    DosFindClose( Handle );                                
    unsignet short Handle;   /*   */         
    

      㭪      ⮫쪮   㬥   ᭮,祭   
DosFindFirst()  뢠 ᪮ ⥫쭮.
         訡,㯠饣       DosFindNext(),ணࠬ
஫  稭  ६  .  㭪   頥
㫥  祭  ⮩  ६,     䠩  㪠
,   .
    ⢥ ਬ  ᬮਬ 室 ᮮ饭  ⮩ ணࠬ,
砥 ᯮ짮   ᪠ 䠩  ७ .EXE:


    C>findmany *.exe
    FINDFIRST.EXE
    GETCOM.EXE
    SETCOM.EXE
    REVERSE.EXE
    FINDMANY.EXE
    C>

   ணࠬ  ⭮  DIR   , 
 ᪮쪮 ⪮. ᥣ  ᯮ짮  ᯥ䨪樥
䠩:      ணࠬ   ப  -
⢥ 㬥  ᫥  䠩 ⥪饩 ४ਨ.  
⠭  ᯥ䨪樨  䠩                  ࠪ⨪.
    ४ਨ  쯥᫥ 䠩,室
  ⮩ ४ਨ. ⠥  䠩  类 ଠ樨  .
 , ᫨  ਬ ᯥ஢ 䠩, 室 
᪮ 横.
    ணࠬ ⠥  ࠭  ஡   ஢
   ⥫쭮  DOS DIR.

    /* dir2.c */
    #define INCL_DOS
    #include <os2.h>
    #include <string.h>          /*  strcpy()  .. */
    #define BUFLEN sizeof(buff)
    #define PATH_LEN 80          /*    */
    #define ATTR 0x0037          /*  ਡ */
    #define DIRECTORY 0x0010     /* ਡ ४਩ */
    #define NO_MORE_FILES 18     /*  訡 dos */

    struct _FILEFINDBUFF buff;   /* ।  doscalls.h */
    unsigned short handle=0xFFFF;/* c  ⮣ 祭 */
    main(argc,argv)
    int argc;
    char *argv[];
    {
         char path[PATH_LEN];    /*   - */
         void pinfo(unsignet);   /* 㭪  ଠ樨 */
         unsigned SearchCount=1;
         int rc;


         if( argc<2 )         /* ᫨  arg, */
             strcpy( path,"*.*" ); /*   ⥪饩 ४ਨ */

                              /* ᫨  ⭠  , */
         else if( strcmp(argv[1],"\\")==0 ) {
             strcpy( path,argv[1] );/*  ୥ ४ */
             strcat( path,"*.*" );  /*   ୥ ४ਨ */
         }
                              /* ᫨ 蠡   ਮ, */
         else if( strcspn(argv[1],"*?.*")<strlen(argv[1]))
             strcpy( path,argv[1] );/*  ᯮ   */
         else {               /* ᫨   㣮 㬥, */
             strcpy( path,argv[1] );/*  । - */
             strcat( path,"\\*.*" );/*   室   */
         printf("Listing pathname &s\n",path );
         rc=DosFindFirst(path,&handle,ATTR,&buff,BUFLEN,
                                                 &SeartchCount,OL);
         pinfo(rc);           /*  ଠ樨 */
         while( TRUE ) {      /*  㣨 室 稭 */
                rc=DosFindNext(handle,&buff,BUFLEN,&SeartchCount,OL);
         pinfo(rc);                  /*  ଠ樨 */
              }
            }

         /* pinfo(rc) */
         /*   ଠ樨  䠩  ४ਨ */
         void pinfo(rc)
         unsigned rc;
         {
             if( rc )

               if( rc==NO_MORE_FILES )
                 { DosFindClose(handle);exit(0); }
               else
                 { printf(DosFindxxx error=&d\n",rc)exit(1);}
             else{
               printf("&-14s",buff.achName );     /*  䠩 */
               if( buff.attrFile & DIRECTORY );
                   printf("&11ss\n","DIR");    /* ४ਨ   */
               else
                   printf("&11s\n",buff.cbFile);/* ࠧ 䠩 */
             }
         }


    ⮩ ணࠬ  㭪 pinfo() ࠡ뢠  㥬 室
    ᮮ饭   訡.㭪 ᯮ   DosFindFirst()
⠪   DosFindNext().       ⠭   䠩 
⠥ ⠪ ࠧ.᫨  ⢥ 室 ଠ樨  ᯮ
४,    䠩,  ᨬ  DIR  ⮡ࠦ    ࠧ.
   ணࠬ           ᪮쪨    묨    室묨
묨.᫨     㬥,⠭          ப,
ணࠬ  ᯮ  ப  "*.*"    ⢥  .᫨
⭠          ⢥  㬥⮬,    
⭮    ୥  ४ਨ,    ணࠬ  믮  
"*.*".


  ணࠬ  dir.c     室         㣨 ਡ⠬,
砥  ᫨    ଠ 䠩,४ਨ,,⥬ 
娢  䠩.,     ਡ  ४ਨ  ⮡ࠦ  
ᯫ.ਬ :


     C>dir2
     FLIGHT.C        4022
     FLIGHT.EXE     27518
     GAMES               <DIR>
     CABBAGE.EXE    33187
     FINANCE             <DIR>
     RELIVE.C        1034
     RELIVE.TXT     12498


   뫮   ஢ ணࠬ   㣨 ਡ.


                    䠩  ४.

      ਬ   dir2.c      ⠫,   ४ਨ    ᮤঠ
䠩,  䠪,  ४ਨ ᮤঠ  ४ਨ
      ᮤঠ  䠩.  ᫥饬,  
ਬ, 뫮  ४,  㭥   ᫥
 䠩.

    ⮣  ਬ          䠩 
४ਨ, 祬    祭 ᪮쪮  㡮    
४.     ⮣  ⮡  ᤥ  ,ணࠬ 믮
४ᨢ.設⢮     ணࠬ     ᮤঠ     㭪,
countdir(),楫 ன       ४ਨ.᭮
ணࠬ 뢠  countdir(), ᯮ  ,஥ ᫥⥫쭮
   ப. countdir() 室 䠩, ਡ
    㬬,襩   室.  countdir()  -
४,  뢠   ,ᯮ     ४ਨ.뢠
୮,  ஢ ४ﬨ  ࠧ 㡨.

    ⢨⥫쭮  । 㡨 ४਩,  
 ஠஢. ࠧ । ࠧ஬ ⥪.  
㬥  countdir()      饭   ⥪, ᫨誮 
  㭪権   뢠     ९.᫨     ⥬
ᯮ        ᪮쪮 ஢ ४਩,
    ࠧ  ⥪  ணࠬ,  ᯮ    \F  
樨 ணࠬ.  㬮砭 ࠧ  ⥪ 2.048   (800).
㤢 ,ਬ,砥 :

            \F 1600

     ப L.⢮    ⭠筮
ଥ.
   ਬ   ⪮஢  ᯮ짮 樨 AL,⠪ 
㭪     printf()     㦤          ᯮ짮   㪠⥫
"far"(ᯮ짮  ᯥ䨪樨  ଠ  "%fs"    㭪樨 printf()
㪠뢠  㪠⥫ ப ⨯ far

    ⥪ ணࠬ:

    /* dirsize */
    /* । 饣 ࠧ  䠩 ४ਨ */
    /*  䠩  ४ ࠧ ஢ */
    /*   AL   far prt  prinf() */
    #define INCL_DOS
    #include <os2.h>
    #include <string.h>          /*  strcat()  .. */
    #define BUFLEN sizeof(buff)  /*   १ */
    #define PATH_LEN 80          /*    */
    #define ATTR 0x0037          /*  ਡ */
    #define DIRECTORY 0x0010     /* ਡ ४ਨ */
    #define NO_MORE_FILES 18     /*  訡 dos */

    unsigned long total=0;       /* 騩 ࠧ ४ਨ */

    main(argc,argv)
    int argc;
    char *argv[];
    {
         void countdir(char far *); /* 㭪    
                                                        ४ਨ */
         char path[80]              /*  ४ਨ  ᪠ */
         if( argc<2 )
             strcpy( path,"\0" );
         else
             strcpy( path,argv[1] );
         countdir( (char far *)path );
         printf("Tjtal bytes in this directory:&lu\n",total );
         exit(0);
     }

     /* countdir() */
     /* */
     /**/
     void countdir( PathPrt )
     char far *PathPrt;
     {
         char localpath[80];
         void entry (char far *, unsigned,struct _FILEFINDBUF *);
         struct _FILEFINDBUF buff;
         unsigned Scnt=1;
         unsigned short handle=0xFFFF;
         unsigned rc;
         if( strlen(PathPrt)>1 )
             strcat(PathPrt,"\\" );
         strcpy( localpath,PathPrt )
         strcat( localpath,"*.*" );

         if( rc=DosFindFirst( localpath,&handle,F_ATTR,&buff,
                                        BUFLEN,&Scnt,OL ) )
             if( rc==NO_MORE_FILES )
                 { DosFindClose( handle);return; }
             else
                 { printf("DosFindFirst error=&d\n",rc),exit(1); }
         entry( PathPrt,handle,&buff );

         while( TRUE ) {
             if( rc==NO_MORE_FILES )
                 { DosFindClose( handle);return; }
             else
                 { printf("DosFindFirst error=&d\n",rc),exit(1); }
         entry( PathPrt,handle,&buff );
          }
      }

     /* entry */
     /**/
     #define NAME buffprt->achName
     #define SIZE buffprt->cbFile
     #define ATTR buffprt->attrFile

     void entry(LosPathPrt,handle,buffprt )
     char far *LosPathPrt;
     unsigned short handle;
     struct _FILEFINDBUF *buffprt;
         { char locpath[80];

           if( ATTR&DIRECTORY ) {        /* ᫨ ४ */
               if( NAME[0]=='.' )        /* ᫨ (.)  (..), */
               return;                   /* 뢠  */
               strcpy( locpath,LocPathPrt ); /* 稭  
                                          ⥬ */
               strcat( locpath,NAME );    /* ਡ  -
                                           ਨ */
               countdir( locpath );        /*   */
            }
           else {
               printf("&s&s=&u\n",LosPathPrt,NAME,SIZE );
               total+=SIZE;                 /*  ࠧ
                                                   䠩 */
                }
           }

     맢 dirsize.c     ,    (
⮬ 砥    ⥪ ४),    ⭮
ᮩ ⮩,㪠뢠饩   ୥ ४.᫨   롨 
    䠩    ୥  ४ਨ,   ᮤন
  䠩,  ணࠬ    ॡ   ⮣ ᪮쪮
.

    㭮   7-3  ᮮ⢥騥   ,뫠
ࠧ묨 㭪ﬨ  ணࠬ,    ⢥ 室  
ப  ᯮ  ᮮ⢥⢥    ப,⭠
  ,㪠뢠     ୥   ४        
४ਨ.

  Ŀ
                                                              
                  
                        DosFindxxx()     countdir()          
                                                              
    Ŀ  
                                                            
                           *.*                 CCC          
                                                            
    Ĵ  
                                                            
           \              \*.*                 CCC          
                                                            
    Ĵ  
                                                            
        \AAA\BBB      \AAA\BBB\*.*       \AAA\BBB\CCC       
                                                            
      
  

 . 7-3.    dirsize.c

   祭 ।,   砥 ᪠,ணࠬ 室
  䠩 , 뢠 ⢨⥫  㬥,ᯮ騩
 祭 DosFindxxx()  ᫥饣 ᪠ countdir().

   ணࠬ 뢠    ࠧ  䠩, ⠪  㬬
    祭  ஫쭮  㬬.  ᪮쪮  ப  筮
襭  ,  ⥪ ४:

     ENVFIND2.EXE=7580
     VERIFY2.C=704
     FILEMODE.EXE=8308
     XXX\XFILE.1=345
     XXX\XFILE.2=456
     XXX\YYY\XFILE11=453
     XXX\YYY\XFILE22=1453
     XXX\YYY\ZZZ\XFILE222=8734
     XXX\YYY\ZZZ\XFILE333=450
     XXX\DIRSIZE.EXE=6787
     DIRSIZE2.C=3843
     DIRSIZE.C=3722
     VERIFY2.EXE=8142
     DIRSIZE2.C=9952
     DIRSIZE.C=8160
     Total bytes in this directory:202795






   ⬥⨬,    dirsize.c    த        ४   
४ ﭭ 䨪 ࠧ 䠩.

    ணࠬ,  ।    ⤥  室
ࠬ  ४ਥ     䠩    믮   ⢥
,ॠ      ⤥쭮   㭪樨:entry().   ᪫砥
᪫砥  㡫஢   ,஥  맢     㭪ﬨ   
countdir: DosFindFirst()  DosFindNext().

     ஢  ணࠬ  믮 㣨 ,
    㭪権    ४ਨ.ਬ, 㤥 㭨⮦
४  楫,  䠩      ४,᫨ 
⠭   䠩   ⮢      뫪,ᯮ   㭪
DosRmdir().


                             

    ᬠਢ 㭪樨,  ଠ   ਡ
䠩,        業஢         ।ᢥ     
ਡ.ࠢ   ,   ᬮॢ      䪭樨,ᯥ樠쭮
।祭    ⥭    䨪樨  ਡ:DosQFileMode() 
DosSetFileMode().

    ⢥ ਬ,᫥  ணࠬ ᯮ   㭪樨 
᪠    ਡ  ࠧ 䠩,     짮⥫
롨  ਡ.  ணࠬ     㠫樨 
䠩  䨪樨 䠩   ਡ⠬ "⮫쪮  ⥭ ".   
 :

     /* filemode */
     /* ⥭    䠩 */
     #define INCL_DOS
     #include <os2.h>
     #include <stdio.h>               /*  getche() */
     #define ATTTR 0x0037             /*  ਡ */
     #define LENGHT sizeof(buff)
     #define READ_ONLY 0x0001
     #define HIGGEN 0x0002
     #define SYSTEM 0x0004
     #define DIRECT 0x0010
     #define ARCHIVE 0x0020

    main(argc,argv)
    int argc;
    char *argv[];
    {
         unsigned attr;                /* ᫮ ਡ */
         int rc;                       /* 頥  */

         if( argc!=2 )
             { printf("Syntax:filemode filename\n); exit(1) }
                                       /*  ਡ 䠩 */
         if( DosQFileMode(argv[1],&attr,OL ) )
             { printf(" DosQFileMode error=&d ",rc); exit(1); }
                                       /* 뢮 ਡ   */
         if( attr=NORMAL )
             printf("Normal file\n");
         else {
         if( attrFile & READ_ONLY ) printf("READ_ONLY\n");
         if( attrFile & HIDDEN) printf("Hidden\n");
         if( attrFile & SYYTEM) printf("System\n");
         if( attrFile & DIRECT) printf("Directory\n");
         if( attrFile & ARCHIVE) printf("Archive\n");
         printf("\n\nChange attributes (y/n)?");
         if( getch()!='y' )
             exit(0);
         attr=NORMAL;                  /*  ਡ */
         printf("\nSet to normal (y/n) ?" );
         if( getch()=='y' )
             attr!=READONLY;
         printf("\nSet to Hidden (y/n) ?" );
         if( getch()=='y' )
             attr!=HIDDEN;
         printf("\nSet to System (y/n) ?" );
         if( getch()=='y' )
             attr!=SYSTEM;
         printf("\nSet to Archive (y/n) ?" );
         if( getch()=='y' )
             attr!= ARCHIVE;
     }                                  /* ⠭ ਡ */
     if( rc=DosSetFileMode(argv[1],attr,OL ))
         { printf("DosSetFileMode error=&d\n);exit(1); }
     }

    ᫥饬 ਬ,믮  ணࠬ  ६ ଠ 䠩
festfile.txt   ८ࠧ㥬    ਡ   祭.⮬,
  ᫥饬 맮 ࠭ 䠩  ଠ쭮.

     C>filemode testfile.txt
     Normal file

     Change attributes(y/n)? y
     Set to normal (y/n)? y
     Set to read-only (y/n)? y
     Set to hidden (y/n)? y
     Set to system (y/n)? y
     Set to archive (y/n)? y
     C>
     C>filemode testfile.txt
     Read-only Hidden System Archive

     Change attrbutes (y/n)? y
     Set to normal (y/n)? y


   ਡ  ४਩         ஢,⮬   
祭  ᯨ᮪ 権  롮., ணࠬ   
 ਡ ४ਨ,ᤥ  ਬ 묨.

   API 㭪樨 ᯮ  ᪠ ਡ 䠩 DosFileMode().
   Ŀ
                  DosQFileMode()-宦 ਡ 䠩.       
    DosQFileMode(Name,Attribute,Reserved );                       
    char far *Name;          /* ASCIIZ  䠩 */               
    unsigned Attribute;      /*  ᫮ ਡ */           
    unsigned long Reserved;  /* १ࢨ஢;  0 */  
   
   ⮩ 㭪樨  室      䠩. 頥 
᫮  ਡ   (ଠ  ⮣    ᫮           㭪
7-2).ணࠬ  ᬮ      ᫮  祭     ⠥
ᮮ⢥騥 ᮮ饭,᫨  祭.

   㭪樥  ⠭ ਡ 䠩  DosSetFileMode().

   Ŀ
                  DosSetFileMode()- ⠭ ਡ 䠩.     
    DosSetFileMode(Name,Attribute,Reserved );                    
    char far *Name;           /* ASCIIZ  䠩 */             
    unsigned Attribute;       /*  ᫮ ਡ *                
    unsigned long Reserved;   /* १ࢨ஢;  0 */
   
      㭪   ॡ         䠩,  ਡ  
஢, ⠪     祭 ᫮  ਡ. 頥
 ਡ, 뫨 ⠭.

                      ⭮ 䠩.

   ਪ  ணࠬ     ॡ          
㪠  䠩.  䠩             ᪮쪨
४਩,      ਪ      ணࠬ                  
.ਬ,ਪ  ணࠬ    ॡ  ⠭
⮯  䠩  樠樨,  API.INI, 
  ⥪饩 ४ਨ,୥ ४ਨ  ४ਨ,
\API\INIT.  ਪ  ணࠬ  । ⢨⥫쭮 
 䠩.

     OS\2  ᯥ樠쭮      楫  ।祭 API 㭪
DosSearchPath().       2  㬥       ப:
䠩, ண 㤥 ⢫, ᯨ᮪ ४਩,ࠧ
窮   ⮩. ।  ⮯ 䠩   ⠥ 
 . ॠ ਪ  ணࠬ  - 䠩  ⭮
 㤥  ᯮ짮   饭   䠩,   뢮.
           ணࠬ  뢠  DosSefrchPath().     2
㬥          ப:  䠩,   ண  㤥
⢫,  ᯨ᮪  ४਩,  ࠧ  窮   ⮩.
।  ⮯  䠩    ⠥  -. ॠ
ਪ ணࠬ  - ⭮     ᯮ- 
 饭  䠩,祬  뢮.

     /* search.c */
     /*   - 䠩 */
     #define INCL_DOS
     #include <os2.h>
     #define LENGTH sizeof(result)   /*   १⠠ */
     #define CONTROL 0x0001          /*  ⥪饩 ४ਨ */

    main(argc,argv)
    int argc;
    char *argv[];
    {
         char result[256];           /*   १ */
         unsigned rc;                /* 䠪᪮ 祭 */

         if( argc!=3 )
             { printf("Syntax: search file path1;path2");exit(1); }
         if( DosSearchPath(CONTROL,argv[2],argv[1],result,LENGHT) )
           if( rc==2 )
              { printf("File not found");exit(1); }
            else
              { printf("DosSearchPath=error &u",rc);exit(1); }
         printf("*s\n",result);
         exit(0);
     }

    ᯮ짮 ⮩ ணࠬ  砥 ᠭ   ᪠
API.INI,㤥   ᫥騩 :

     C>search app.ini \;\app\init
     C:\APP\INIT

       砥  䠩  API.INI      ४ਨ   \\INIT,
ணࠬ   ⠪   믮            ⥪饩    ୥
४ਨ.ப  \;  app\init,     ணࠬ  ᪠
䠩     㣨  ୥   ४       \app\init.ࠬ
DosSearchPath() ।뢠 ᬮ ⥪ ४

   ᫨ 䠩 APP.INI 室  ⥪饩 ४ਨ,  \CHAP8\
NOTES,    ⢨    ணࠬ  룫拉 ᫥騬
ࠧ:

         C>search app.ini \;\app\init
         C:\CHAP8\NOTES

    ᫨ 䠩  㤠      ४,뤠
ᮮ饭 "    ".
   Ŀ
                  DosSearchPath-  .                
         DosSearchPath( Control,Path,File,Buffer,Lenght )           
         unsigned Control;        /* ⥪ ४  ,    
                                     ६  㦥   *
         char far *Path;          /* ASCIIZ ᯨ᮪   */   
         char far *File;          /* ASCIIZ  䠩 */            
         char far *ABuffer;       /*   १ */     
         unsigned  Length;        /*   १ */    
   

     ࠬ஬  DosSearchPath()    ࠢ饥   ᫮,
஥  ᯮ  ⮢      ।     ࠧ
権. ᫮   㭪 7-4:

  Ŀ
                                                            
                                             
      ....  Ŀ          
                                                      
       15    14               2    1    0             
                                                      
       .....          
                                                          
       ⪠                    
      0=䠪᪨                                    
      1=६ 㦥                               
                                                           
       ⥪饩 ⠭             
      0= ⮬᪮ ᪠ ⥪饩                  
        ४ਨ                                          
      1=⥪ ४  ࢮ                    
                                                            
  
  . 7-4. ࠢ饥 ᫮  DosSearchPath().

   㫥   ஫쭮 ᫮  "⥪  ⠭"(implied
current).᫨   ⠭,㭪  ⥪ ४  
䠩,  ।⥫쭮  믮     ४ਨ  ᯨ᪥
४਩.᫨    ⠭,⥪  ४   ,᫨
⮫쪮  ᯥ樠쭮  㪠-    ᪠(  ᯮ짮
横). ਬ   ⠭      ⥪  ४ 㤥
.

   ன   "筨 ".  ,    -
: search.c  ⠭  "0".

   ன ࠬ ASCIIZ  ப ᮤন   , 
᪠,ࠧ 窮  ⮩.

   ⨩   ࠬ   ASCIIZ   ப   -     䠩,  㤥
᪠.   ᮤঠ 蠡 (wildcard). 䠩
 蠡   ᯮ짮  㭪   ਪ
ணࠬ,  㦤      㯯    
.  ᯮ짮  室  DosFindFirst() 
DosFindNext().

   ⢥ ࠬ஬     , ⥬  ᮤন
    䠩.    ᫥  ࠬ       
१⮢.

                      ६ 㦥.

   쭮    ࠭    砩,     ஬       
(pathname)    㦥,  ⮬    ⤥  ४
  뫠,ᯮ  ६  㦥. ਬ,
Microsoft  C  ᯮ    ⥬   饭  ४ਨ LIB
ᯮ ६ LIB.짮⥫  ᯮ  ४
 㣮,   㦥    ᮤঠ  ⮪,,  
室.   ਬ :

     LIB=C:\C5\LIB

   ᯮ ⮫쪮   LIB,  ।     
䠩  㣮 ४ਨ.

             ᯮ짮   API  㭪権    ६
㦥  ᪠   ⤥ 䠩. ⮤ 
  த஢    ⮬    祭  ६
CONTPOL    ணࠬ  search..᫨    "筨 "( 1)
⠭  1, DosSearchParth()   ⢥  㬥⮢
  ६  㦥,       .   ᯮ좠
⮫쪮 筠  ६;窠   ⮩   ਬ,᫨ 
筨 ⠭.

   ன      ᯮ짮    ६   㦥   ᪠
䠩  -    ८ࠧ  ६  㦥  ᮮ⢥饥
     䠩,ᯮ   ᯥ樠쭮  ࠧࠡ⠭    ⮣
㭪 DosScanEvn(). 㭪  ६ 㦥  ⢥
室  稭            祭(筮         
᫥⥫쭮     ),ᮢ饥            ⥪饩
४ਨ.  ⮤   ᫮, 祬   稭
CONTROL  DosSearchPath()

Ŀ
                DosScanEvn- ᬮ 㦥.                    
  DosScanEvn( VarNave,BuffPrt );                                   
  char far *VarName;      /* ASCIIZ  ६ 㦥    */ 
  char far * char far *BuffPrt; /*   㪠⥫ ப */ 


   DosScanEvn()    ⢥ 室   ६ 㦥,
頥 㪠⥫   ᮮ⢥饥 祭 ப,  
 㭪 7-5:

 Ŀ
                   Entry in environment                          
           Ŀ                 
                                                                 
           I N I T =  c :\ o s 2 \ i n i t i a l                 
                                                                
                DosSearchPath()    
                                             頥 㪠-  
  Input to                                ⥫   ᨬ-  
  DosSearchPath()                                             
 
                          Figure 7-5
               ⥫  祭 㦥.


    ணࠬ,   ᯮ DosScanEvn()    DosSearchPath()
 ᪠   䠩, ᯮ ६ 㦥.

     /* envfind.c */
     /*  䠩 ᯮ ६ 㦥 */
     #define INCL_DOS
     #include <os2.h>
     #define LENGTH sizeof(result)   /* ࠧ  १ */
     #define CONTROL 0x0001          /*  ⥪饩 ४ਨ */
    main(argc,argv)
    int argc;
    char *argv[];
    {
         char far *PathPrt;        /* 㪠⥫  ப 㦥 */
         char result[256];         /*   १ */
         unsigned rc;              /*  १ */
         if( argc!=3 )             /* 砫  ६ 㦥 */
            { printf("Syntax:envfind filename ENVVAR "); exit(1); }
                                   /* 祭 ⥪饣 - */
         if( rc=DosScanEvn( argv[2],&PathPrt ) )
            { printf("DosScanEvn error=&u,rc); exit(1); }
                                   /*   */
         if( DosSearchPath(CONTROL,PathPrt,argv[1],result,LENGHT ) )
           if( rc==2 )
              { printf("File not found");exit(1); }
         else
              { printf("DosSearchPath=error &u",rc);exit(1); }
           printf("*s\n",result);
           exit(0);
     }
   ।, । ᮤন ப :

     INIT=c:\os2\inital

       ⠪,     䠩    ED.INI     室         ४ਨ
C:\OS2\INITAL.᫨   맮   envfind.c   ᪠   
⮣ 䠩,  㢨:

     C>envfind ed.ini INIT
     C:\OS2\INITAL

   ६   㦥          ⠭     묨
㪢,᫨     뫠           ⠪       ⠭
㦥.  ணࠬ 頥   䠩.

   㭪 DosScanEvn()   ६  㦥 INIT,   ।
  ,  ᮮ⢥饥      C:/OS2/INIT.  ⮬,
DosSearchPath()  䠩  ed.inv  ⮩  ப  頥  .᫨
  "⥪饩  ⠭"(implied   current)  ⠭,     ⠪
ᬠਢ ⥪  ४,    砥   室  ⠬
䠩.


                                                         7

            ᫥  ࠧ   API 㭪樨,
  䠩       楫.  㢨,  ᮧ   
㭨⮦ ४ਨ    DosMkDir()   DosRmDir, ⥪
४(   ⤥쭠    ਪ   ணࠬ)        
,ᯮ  DosQCurDir(),      ⥪饣  ࠩ 
᪠   ,ᯮ DosQCurDisk()  DosSelectDisk().

           㭨⮦      ७ᥭ       
४ਨ    २ c  API 㭪樨 DosMove().

   㭪樨   DosFindFirst(),DosFindNext()   DosFindClose(), 
ᯮ짮   祭    䠩,ᮢ    ।
蠡,       蠡  .  ,
 㭪樨 ਬ   , ணࠬ ᪠
४਩  ணࠬ   ४ਨ.

     䠩  (  ⠪      read-only,hidden,system,archive,
४ਨ)      DosQFileMode()   
DosSetFileMode().

    , ,    ᬮ५,      ਪ  ணࠬ 
ᯮ짮  DosSearchPath()    ᪠     㪠 䠩,
DosScanEnv()   ᪠ 䠩,     ஬ 㪠   ६
㦥.

    ᫥饩    㢨,     묨 䠩,
ࠡ     ᮤন.
