1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
23 //------------------------------------------------------------------------
25 //------------------------------------------------------------------------
30 #include <Standard_ProgramError.hxx>
31 #include <OSD_OSDError.hxx>
32 #include <OSD_WhoAmI.hxx>
33 #include <OSD_FromWhere.hxx>
34 #include <OSD_File.ixx>
36 #include <Standard_PCharacter.hxx>
38 const OSD_WhoAmI Iam = OSD_WFile;
40 #if defined (sun) || defined(SOLARIS)
56 #ifdef HAVE_SYS_TYPES_H
57 # include <sys/types.h>
60 #ifdef HAVE_SYS_STAT_H
61 # include <sys/stat.h>
64 #define NEWLINE '\10';
66 // ---------------------------------------------------------------------
67 // Create an empty file object
68 // ---------------------------------------------------------------------
70 OSD_File::OSD_File():OSD_FileNode() {
71 ImperativeFlag = Standard_False;
74 myMode = OSD_ReadWrite;
76 myFILE = (Standard_Address) NULL;
79 // ---------------------------------------------------------------------
80 // Create and initialize a file object
81 // ---------------------------------------------------------------------
83 OSD_File::OSD_File(const OSD_Path& Name):OSD_FileNode(Name){
85 ImperativeFlag = Standard_False;
88 myMode = OSD_ReadWrite;
90 myFILE = (Standard_Address) NULL;
94 // ---------------------------------------------------------------------
95 // Build a file if it doesn't exist or create again if it already exists
96 // ---------------------------------------------------------------------
98 void OSD_File::Build(const OSD_OpenMode Mode,
99 const OSD_Protection& Protect){
101 Standard_Integer internal_prot;
102 Standard_Integer internal_mode = O_CREAT | O_TRUNC ;
103 TCollection_AsciiString aBuffer;
105 if (myPath.Name().Length()==0)
106 Standard_ProgramError::Raise("OSD_File::Build : no name was given");
108 if (myFileChannel != -1)
109 Standard_ProgramError::Raise("OSD_File::Build : file is already open");
114 internal_prot = Protect.Internal();
120 internal_mode |= O_RDONLY;
124 internal_mode |= O_WRONLY;
128 internal_mode |= O_RDWR;
133 myPath.SystemName( aBuffer );
134 myFileChannel = open (aBuffer.ToCString(),(int) internal_mode,(int) internal_prot);
135 if (myFileChannel >= 0) {
136 myFILE = fdopen (myFileChannel,(const char*) CMode);
139 /* Handle OPEN errors */
141 myError.SetValue (errno, Iam, "Open");
147 // ---------------------------------------------------------------------
148 // Append to an existing file
149 // ---------------------------------------------------------------------
151 void OSD_File::Append(const OSD_OpenMode Mode,
152 const OSD_Protection& Protect){
154 Standard_Integer internal_prot;
155 Standard_Integer internal_mode = O_APPEND;;
156 TCollection_AsciiString aBuffer;
158 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
159 Standard_ProgramError::Raise("OSD_File::Append : it is a directory");
162 if (myPath.Name().Length()==0)
163 Standard_ProgramError::Raise("OSD_File::Append : no name was given");
165 if (myFileChannel != -1)
166 Standard_ProgramError::Raise("OSD_File::Append : file is already open");
168 internal_prot = Protect.Internal();
176 internal_mode |= O_RDONLY;
180 internal_mode |= O_WRONLY;
184 internal_mode |= O_RDWR;
189 // If file doesn't exist, creates it.
191 if (!Exists()) internal_mode |= O_CREAT;
193 myPath.SystemName ( aBuffer );
194 myFileChannel = open (aBuffer.ToCString(),(int) internal_mode,(int) internal_prot);
195 if (myFileChannel >= 0)
196 myFILE = fdopen (myFileChannel,(const char*) CMode);
198 /* Handle OPEN errors */
200 myError.SetValue (errno, Iam, "Open");
203 // ---------------------------------------------------------------------
205 // ---------------------------------------------------------------------
207 void OSD_File::Open(const OSD_OpenMode Mode,
208 const OSD_Protection& Protect){
210 Standard_Integer internal_prot;
211 Standard_Integer internal_mode = 0;
212 TCollection_AsciiString aBuffer;
214 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
215 myError.SetValue (1, Iam, "Could not be open : it is a directory");
218 if (myPath.Name().Length()==0)
219 Standard_ProgramError::Raise("OSD_File::Open : no name was given");
221 if (myFileChannel != -1)
222 Standard_ProgramError::Raise("OSD_File::Open : file is already open");
224 internal_prot = Protect.Internal();
232 internal_mode |= O_RDONLY;
236 internal_mode |= O_WRONLY;
240 internal_mode |= O_RDWR;
245 myPath.SystemName ( aBuffer );
246 myFileChannel = open (aBuffer.ToCString(),(int) internal_mode,(int) internal_prot);
247 if (myFileChannel >= 0)
248 myFILE = fdopen (myFileChannel,(const char*) CMode);
250 /* Handle OPEN errors */
252 myError.SetValue (errno, Iam, "Open");
257 // ---------------------------------------------------------------------
258 // ---------------------------------------------------------------------
259 OSD_File OSD_File::BuildTemporary(){
261 #if defined(vax) || defined(__vms) || defined(VAXVMS)
267 dummy = open("dummy", O_RDWR | O_CREAT); // Open a summy file
268 result.myFileChannel = dummy - 1; // This is file channel of "fic" +1
269 close(dummy); // Close dummy file
270 unlink("dummy"); // Removes dummy file
274 char *name = tmpnam((char*) 0) ;
277 TCollection_AsciiString aName ( name ) ;
278 OSD_Path aPath( aName ) ;
280 result.SetPath( aPath ) ;
282 result.myFILE = fopen( name, "w+" ) ;
284 result.myFileChannel = fileno( (FILE*)result.myFILE );
288 result.myMode = OSD_ReadWrite;
295 // ---------------------------------------------------------------------
296 // Read content of a file
297 // ---------------------------------------------------------------------
299 void OSD_File::Read(TCollection_AsciiString& Buffer,
300 const Standard_Integer Nbyte){
301 Standard_PCharacter readbuf;
304 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
305 Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
308 if (myFileChannel == -1)
309 Standard_ProgramError::Raise("OSD_File::Read : file is not open");
311 if (Failed()) Perror();
313 if (myMode == OSD_WriteOnly)
314 Standard_ProgramError::Raise("OSD_File::Read : file is Write only");
317 Standard_ProgramError::Raise("OSD_File::Read : Nbyte is null");
319 TCollection_AsciiString transfert(Nbyte,' ');
320 readbuf = (Standard_PCharacter)transfert.ToCString();
322 status = read( (int)myFileChannel, readbuf, Nbyte);
324 Buffer = transfert; // Copy transfert to Buffer
326 if (status == -1) myError.SetValue (errno, Iam, "Read");
328 if ( status < Nbyte ) myIO = EOF;
332 // ---------------------------------------------------------------------
333 // Read a line from a file
334 // ---------------------------------------------------------------------
336 void OSD_File::ReadLine(TCollection_AsciiString& Buffer,
337 const Standard_Integer Nbyte,
338 Standard_Integer& NByteRead)
340 Standard_PCharacter readbuf, abuffer;
342 if (OSD_File::KindOfFile() == OSD_DIRECTORY ) {
343 Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
345 if (myFileChannel == -1){
346 Standard_ProgramError::Raise("OSD_File::ReadLine : file is not open");
351 if (myMode == OSD_WriteOnly) {
352 Standard_ProgramError::Raise("OSD_File::ReadLine : file is Write only");
355 Standard_ProgramError::Raise("OSD_File::ReadLine : Nbyte is null");
358 TCollection_AsciiString transfert(Nbyte,' ');
359 readbuf = (Standard_PCharacter)transfert.ToCString();
361 abuffer = fgets(readbuf, Nbyte, (FILE *) myFILE);
363 if (abuffer == NULL) {
364 if (!feof((FILE *) myFILE)) {
365 myError.SetValue (errno, Iam, "ReadLine");
375 NByteRead = strlen(abuffer);
376 Buffer.SetValue(1,abuffer); // Copy transfert to Buffer
377 Buffer.Trunc(NByteRead);
380 // --------------------------------------------------------------------------
381 // OSD::KindOfFile Retourne le type de fichier.
382 // --------------------------------------------------------------------------
383 OSD_KindFile OSD_File::KindOfFile ( ) const{
386 TCollection_AsciiString FullName;
390 aPath.SystemName (FullName);
391 status = stat (FullName.ToCString() , &buffer );
393 if ( S_ISDIR(buffer.st_mode) ) { return OSD_DIRECTORY ; }
394 else if ( S_ISREG(buffer.st_mode) ) { return OSD_FILE ; }
395 else if ( S_ISLNK(buffer.st_mode) ) { return OSD_LINK ; }
396 else if ( S_ISSOCK(buffer.st_mode) ) { return OSD_SOCKET ; }
397 else { return OSD_UNKNOWN ; }
402 // --------------------------------------------------------------------------
403 // Read content of a file
404 // --------------------------------------------------------------------------
405 void OSD_File::Read( Standard_Address& Buffer,
406 const Standard_Integer Nbyte,
407 Standard_Integer& Readbyte)
412 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
413 Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
416 if (myFileChannel == -1)
417 Standard_ProgramError::Raise("OSD_File::Read : file is not open");
419 if (Failed()) Perror();
421 if (myMode == OSD_WriteOnly)
422 Standard_ProgramError::Raise("OSD_File::Read : file is Write only");
425 Standard_ProgramError::Raise("OSD_File::Read : Nbyte is null");
428 Standard_ProgramError::Raise("OSD_File::Read : Buffer is null");
430 status = read( (int)myFileChannel, (char*) Buffer, Nbyte);
432 if (status == -1) myError.SetValue (errno, Iam, "Read");
434 if ( status < Nbyte ) myIO = EOF;
435 Readbyte = (Standard_Integer) status;
439 // Write content of a file
441 void OSD_File::Write(const TCollection_AsciiString &Buffer,
442 const Standard_Integer Nbyte){
444 Standard_CString writebuf;
447 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
448 Standard_ProgramError::Raise("OSD_File::Write : it is a directory");
451 if (myFileChannel == -1)
452 Standard_ProgramError::Raise("OSD_File::Write : file is not open");
454 if (Failed()) Perror();
456 if (myMode == OSD_ReadOnly)
457 Standard_ProgramError::Raise("OSD_File::Write : file is Read only");
460 Standard_ProgramError::Raise("OSD_File::Write : Nbyte is null");
462 writebuf = Buffer.ToCString();
464 status = write( (int)myFileChannel, writebuf, Nbyte);
466 if ( status == -1) myError.SetValue (errno, Iam, "Write");
468 if ( status < Nbyte ) myIO = EOF;
472 void OSD_File::Write(const Standard_Address Buffer,
473 const Standard_Integer Nbyte)
478 if (myFileChannel == -1)
479 Standard_ProgramError::Raise("OSD_File::Write : file is not open");
481 if (Failed()) Perror();
483 if (myMode == OSD_ReadOnly)
484 Standard_ProgramError::Raise("OSD_File::Write : file is Read only");
487 Standard_ProgramError::Raise("OSD_File::Write : Nbyte is null");
489 status = write( (int)myFileChannel, (const char *)Buffer, Nbyte);
491 if ( status == -1) myError.SetValue (errno, Iam, "Write");
493 if ( status < Nbyte ) myIO = EOF;
500 // Move file pointer to a specified position
502 void OSD_File::Seek(const Standard_Integer Offset,
503 const OSD_FromWhere Whence){
506 if (myFileChannel == -1)
507 Standard_ProgramError::Raise("OSD_File::Seek : file is not open");
509 if (Failed()) Perror();
512 case OSD_FromBeginning :
522 myError.SetValue (EINVAL, Iam, "Seek");
524 status = (int) lseek( (int)myFileChannel, Offset, where );
526 if (status == -1) myError.SetValue (errno, Iam, "Seek");
536 void OSD_File::Close(){
539 if (myFileChannel == -1)
540 Standard_ProgramError::Raise("OSD_File::Close : file is not open");
542 if (Failed()) Perror();
544 status = close ( (int) myFileChannel );
546 if (status == -1) myError.SetValue (errno, Iam, "Close");
548 if ( myFILE != NULL ) {
549 status = fclose ( (FILE*) myFILE );
550 myFILE = (Standard_Address) NULL;
558 // --------------------------------------------------------------------------
559 // Test if at end of file
560 // --------------------------------------------------------------------------
562 Standard_Boolean OSD_File::IsAtEnd(){
563 if (myFileChannel == -1)
564 Standard_ProgramError::Raise("OSD_File::IsAtEnd : file is not open");
566 if (myIO == EOF) return (Standard_True);
567 return (Standard_False);
572 /*void OSD_File::Link(const TCollection_AsciiString& ToFile){
573 if (myFileChannel == -1)
574 Standard_ProgramError::Raise("OSD_File::Link : file is not open");
576 TCollection_AsciiString aBuffer;
577 myPath.SystemName ( aBuffer );
578 link ( aBuffer.ToCString(), ToFile.ToCString() );
584 void OSD_File::SetLock(const OSD_LockType Lock){
587 if (myFileChannel == -1)
588 Standard_ProgramError::Raise("OSD_File::SetLock : file is not open");
596 case OSD_ExclusiveLock :
597 case OSD_WriteLock : lock = F_LOCK;
599 case OSD_ReadLock : return;
601 default : myError.SetValue (EINVAL, Iam, "SetLock");
605 if (fstat((int)myFileChannel, &buf) == -1) {
606 myError.SetValue (errno, Iam, "SetLock");
610 status = lockf(myFileChannel, lock, buf.st_size);
611 if (status == -1) myError.SetValue (errno, Iam, "SetLock");
620 case OSD_ExclusiveLock :
621 case OSD_WriteLock : key.l_type = F_WRLCK;
623 case OSD_ReadLock : key.l_type = F_RDLCK;
625 case OSD_NoLock : return;
626 // default : myError.SetValue (EINVAL, Iam, "SetLock");
633 status = fcntl( (int) myFileChannel ,F_SETLKW,(long) &key);
634 if (status == -1) myError.SetValue (errno, Iam, "SetLock");
637 if (Lock == OSD_ExclusiveLock){
638 fstat( (int) myFileChannel ,&buf);
639 TCollection_AsciiString aBuffer;
640 myPath.SystemName ( aBuffer );
641 chmod( aBuffer.ToCString() ,buf.st_mode | S_ISGID);
642 ImperativeFlag = Standard_True;
649 case OSD_ExclusiveLock :
650 case OSD_WriteLock : lock = F_WRLCK;
652 case OSD_ReadLock : lock = F_RDLCK;
654 default : myError.SetValue (EINVAL, Iam, "SetLock");
657 status = flock((int)myFileChannel,lock);
658 if (status == -1) myError.SetValue (errno, Iam, "SetLock");
667 // Remove a lock from a file
669 void OSD_File::UnLock(){
672 if (myFileChannel == -1)
673 Standard_ProgramError::Raise("OSD_File::UnLock : file is not open");
678 if (fstat(myFileChannel, &buf) == -1) {
679 myError.SetValue(errno, Iam, "UnsetLock");
683 status = lockf(myFileChannel,F_ULOCK, buf.st_size);
684 if (status == -1) myError.SetValue (errno, Iam, "SetLock");
692 fstat((int)myFileChannel,&buf);
693 TCollection_AsciiString aBuffer;
694 myPath.SystemName ( aBuffer );
695 chmod(aBuffer.ToCString(),buf.st_mode & ~S_ISGID);
696 ImperativeFlag = Standard_False;
698 key.l_type = F_UNLCK;
699 status = fcntl((int)myFileChannel,F_SETLK,(long) &key);
700 if (status == -1) myError.SetValue (errno, Iam, "UnSetLock");
703 status = flock((int)myFileChannel,LOCK_UN);
704 if (status == -1) myError.SetValue (errno, Iam, "UnSetLock");
707 else myLock = OSD_NoLock;
714 // Return lock of a file
716 OSD_LockType OSD_File::GetLock(){
717 if (myFileChannel == -1)
718 Standard_ProgramError::Raise("OSD_File::GetLock : file is not open");
726 // --------------------------------------------------------------------------
727 // Return size of a file
728 // --------------------------------------------------------------------------
730 Standard_Integer OSD_File::Size(){
734 if (myPath.Name().Length()==0)
735 Standard_ProgramError::Raise("OSD_File::Size : empty file name");
737 TCollection_AsciiString aBuffer;
738 myPath.SystemName ( aBuffer );
739 status = stat( aBuffer.ToCString() ,&buffer );
741 myError.SetValue (errno, Iam, "Size");
745 return ( buffer.st_size );
749 // --------------------------------------------------------------------------
750 // Print contains of a file
751 // --------------------------------------------------------------------------
753 void OSD_File::Print (const OSD_Printer &WhichPrinter ){
755 TCollection_AsciiString PrinterName;
757 if (myPath.Name().Length()==0)
758 Standard_ProgramError::Raise("OSD_File::Print : empty file name");
760 WhichPrinter.Name(PrinterName);
762 TCollection_AsciiString aBuffer;
763 myPath.SystemName ( aBuffer );
765 if (PrinterName.Length()==0)
766 sprintf(buffer,"lp %s",aBuffer.ToCString());
768 sprintf(buffer,"lpr -P%s %s",PrinterName.ToCString(),aBuffer.ToCString());
774 // --------------------------------------------------------------------------
775 // Test if a file is open
776 // --------------------------------------------------------------------------
778 Standard_Boolean OSD_File::IsOpen()const{
780 if (myPath.Name().Length()==0)
781 Standard_ProgramError::Raise("OSD_File::IsOpen : empty file name");
783 return (myFileChannel != -1);
787 Standard_Boolean OSD_File::IsLocked(){
789 if (myPath.Name().Length()==0)
790 Standard_ProgramError::Raise("OSD_File::IsLocked : empty file name");
792 return(myLock != OSD_NoLock);
795 Standard_Boolean OSD_File::IsReadable()
797 TCollection_AsciiString FileName ;
799 myPath.SystemName(FileName) ;
801 if (access(FileName.ToCString(),F_OK|R_OK))
802 return Standard_False;
804 return Standard_True;
807 Standard_Boolean OSD_File::IsWriteable()
809 TCollection_AsciiString FileName ;
811 myPath.SystemName(FileName) ;
813 if (access(FileName.ToCString(),F_OK|R_OK|W_OK))
814 return Standard_False;
816 return Standard_True;
819 Standard_Boolean OSD_File::IsExecutable()
821 TCollection_AsciiString FileName ;
823 myPath.SystemName(FileName) ;
825 if (access(FileName.ToCString(),F_OK|X_OK))
826 return Standard_False;
828 return Standard_True;
833 //------------------------------------------------------------------------
834 //------------------- Windows NT sources for OSD_File -------------------
835 //------------------------------------------------------------------------
839 #include <OSD_File.hxx>
840 #include <OSD_Protection.hxx>
841 #include <OSD_Printer.hxx>
842 #include <Standard_ProgramError.hxx>
844 #include <OSD_WNT_1.hxx>
848 #include <Standard_PCharacter.hxx>
854 #if defined(__CYGWIN32__) || defined(__MINGW32__)
859 #pragma comment( lib, "WSOCK32.LIB" )
860 #pragma comment( lib, "WINSPOOL.LIB" )
862 #define ACE_HEADER_SIZE ( sizeof ( ACCESS_ALLOWED_ACE ) - sizeof ( DWORD ) )
864 #define RAISE( arg ) Standard_ProgramError :: Raise ( ( arg ) )
865 #define TEST_RAISE( arg ) _test_raise ( myFileChannel, ( arg ) )
869 #define OPEN_APPEND 2
871 void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
872 PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, char* = NULL );
873 BOOL __fastcall _osd_wnt_sd_to_protection (
874 PSECURITY_DESCRIPTOR, OSD_Protection&, BOOL
876 BOOL __fastcall _osd_print (const Standard_PCharacter, Standard_CString );
878 static void __fastcall _test_raise ( Standard_Integer, Standard_CString );
879 static DWORDLONG __fastcall _get_line ( Standard_PCharacter&, DWORD );
880 static int __fastcall _get_buffer ( HANDLE, Standard_PCharacter&, DWORD, BOOL, BOOL );
881 static DWORD __fastcall _get_access_mask ( OSD_SingleProtection );
882 static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt );
883 static HANDLE __fastcall _open_file ( Standard_CString, OSD_OpenMode, DWORD, LPBOOL = NULL );
885 static OSD_SingleProtection __fastcall _get_protection ( DWORD );
886 static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD );
888 typedef OSD_SingleProtection ( __fastcall *GET_PROT_FUNC ) ( DWORD );
890 Standard_Integer __fastcall _get_file_type ( Standard_CString, Standard_Integer );
892 // ---------------------------------------------------------------------
893 // Create an empty file object
894 // ---------------------------------------------------------------------
896 OSD_File :: OSD_File () {
898 ImperativeFlag = Standard_False;
902 } // end constructor ( 1 )
904 // ---------------------------------------------------------------------
905 // Create and initialize a file object
906 // ---------------------------------------------------------------------
908 OSD_File :: OSD_File ( const OSD_Path& Name ) : OSD_FileNode ( Name ) {
910 ImperativeFlag = Standard_False;
915 } // end constructor ( 2 )
917 // ---------------------------------------------------------------------
918 // Build a file if it doesn't exist or create again if it already exists
919 // ---------------------------------------------------------------------
921 void OSD_File :: Build (
922 const OSD_OpenMode Mode, const OSD_Protection& Protect
925 TCollection_AsciiString fName;
927 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
928 Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
931 if ( ( HANDLE )myFileChannel != INVALID_HANDLE_VALUE )
933 RAISE( TEXT( "OSD_File :: Build (): incorrect call - file already opened" ) );
936 myPath.SystemName ( fName );
938 if ( fName.IsEmpty () )
940 RAISE( TEXT( "OSD_File :: Build (): incorrent call - no filename given" ) );
942 myFileChannel = ( Standard_Integer )_open_file ( fName.ToCString (), Mode, OPEN_NEW );
944 if ( ( HANDLE )myFileChannel == INVALID_HANDLE_VALUE )
946 _osd_wnt_set_error ( myError, OSD_WFile );
950 SetProtection ( Protect );
955 } // end OSD_File :: Build
959 // ---------------------------------------------------------------------
961 // ---------------------------------------------------------------------
963 void OSD_File :: Open (
964 const OSD_OpenMode Mode, const OSD_Protection& Protect
967 TCollection_AsciiString fName;
970 if ( ( HANDLE )myFileChannel != INVALID_HANDLE_VALUE )
972 RAISE( TEXT( "OSD_File :: Open (): incorrect call - file already opened" ) );
975 myPath.SystemName ( fName );
977 if ( fName.IsEmpty () )
979 RAISE( TEXT( "OSD_File :: Open (): incorrent call - no filename given" ) );
981 myFileChannel = ( Standard_Integer )_open_file ( fName.ToCString (), Mode, OPEN_OLD );
983 if ( ( HANDLE )myFileChannel == INVALID_HANDLE_VALUE ) {
985 _osd_wnt_set_error ( myError, OSD_WFile );
989 myIO |= _get_file_type ( fName.ToCString (), myFileChannel );
991 } // end OSD_File :: Open
993 // ---------------------------------------------------------------------
994 // Append to an existing file
995 // ---------------------------------------------------------------------
997 void OSD_File :: Append (
998 const OSD_OpenMode Mode, const OSD_Protection& Protect
1002 TCollection_AsciiString fName;
1004 if ( ( HANDLE )myFileChannel != INVALID_HANDLE_VALUE )
1006 RAISE( TEXT( "OSD_File :: Append (): incorrect call - file already opened" ) );
1009 myPath.SystemName ( fName );
1011 if ( fName.IsEmpty () )
1013 RAISE( TEXT( "OSD_File :: Append (): incorrent call - no filename given" ) );
1015 myFileChannel = ( Standard_Integer )_open_file ( fName.ToCString (), Mode, OPEN_APPEND, &fNew );
1017 if ( ( HANDLE )myFileChannel == INVALID_HANDLE_VALUE )
1019 _osd_wnt_set_error ( myError, OSD_WFile );
1025 myIO |= _get_file_type ( fName.ToCString (), myFileChannel );
1026 Seek ( 0, OSD_FromEnd );
1030 SetProtection ( Protect );
1037 } // end OSD_File :: Append
1039 // ---------------------------------------------------------------------
1040 // Read content of a file
1041 // ---------------------------------------------------------------------
1043 void OSD_File :: Read (
1044 TCollection_AsciiString& Buffer, const Standard_Integer Nbyte
1047 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
1048 cout << " OSD_File::Read : it is a directory " << endl;
1050 // Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
1053 Standard_Integer NbyteRead;
1054 Standard_Address buff;
1056 TEST_RAISE( TEXT( "Read" ) );
1058 buff = ( Standard_Address )new Standard_Character[ Nbyte + 1 ];
1060 Read ( buff, Nbyte, NbyteRead );
1062 ( ( Standard_PCharacter )buff )[ NbyteRead ] = 0;
1064 if ( NbyteRead != 0 )
1066 Buffer = ( Standard_PCharacter )buff;
1074 } // end OSD_File :: Read
1078 // ---------------------------------------------------------------------
1079 // Read a line from a file
1080 // ---------------------------------------------------------------------
1084 // Modified so that we have <nl> at end of line if we have read <nl> or <cr>
1086 // by LD 17 dec 98 for B4.4
1088 void OSD_File :: ReadLine (
1089 TCollection_AsciiString& Buffer,
1090 const Standard_Integer NByte, Standard_Integer& NbyteRead
1096 Standard_Character peekChar;
1097 Standard_PCharacter ppeekChar;
1098 Standard_PCharacter cBuffer;
1099 Standard_CString eos;
1102 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
1103 Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
1106 TEST_RAISE( TEXT( "ReadLine" ) );
1108 if ( myIO & FLAG_PIPE && !( myIO & FLAG_READ_PIPE ) )
1110 RAISE( TEXT( "OSD_File :: ReadLine (): attempt to read from write only pipe" ) );
1112 // +----> leave space for end-of-string
1113 // | plus <CR><LF> sequence
1116 ppeekChar=&peekChar;
1117 cBuffer = new Standard_Character[ NByte + 3 ];
1119 if ( myIO & FLAG_FILE ) {
1122 ( HANDLE )myFileChannel, cBuffer, ( DWORD )NByte, &dwBytesRead, NULL
1124 ) { // an error occured
1126 _osd_wnt_set_error ( myError, OSD_WFile );
1130 } else if ( dwBytesRead == 0 ) { // end-of-file reached
1137 myIO &= ~FLAG_EOF ; // if the file increased since last read (LD)
1138 status = _get_line ( cBuffer, dwBytesRead );
1140 dwSeekPos = LODWORD( status );
1141 eos = ( Standard_CString )HIDWORD( status );
1143 if ( (__int64) status == (__int64) -1 ) { // last character in the buffer is <CR> -
1145 if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is <CR> -
1146 // peek next character to see if it is a <LF>
1149 ( HANDLE )myFileChannel, ppeekChar, 1, &dwDummy, NULL
1153 _osd_wnt_set_error ( myError, OSD_WFile );
1155 } else if ( dwDummy != 0 ) { // end-of-file reached ?
1157 if ( peekChar != '\n' ) // if we did not get a <CR><LF> sequence
1159 // adjust file position
1161 SetFilePointer ( ( HANDLE )myFileChannel, -1, NULL, FILE_CURRENT );
1166 NbyteRead = dwBytesRead;
1170 if ( dwSeekPos != 0 )
1171 SetFilePointer ( ( HANDLE )myFileChannel, ( LONG )dwSeekPos, NULL, FILE_CURRENT );
1173 NbyteRead = ( Standard_Integer )( eos - cBuffer );
1179 } else if ( myIO & FLAG_SOCKET || myIO & FLAG_PIPE || myIO & FLAG_NAMED_PIPE ) {
1181 dwBytesRead = ( DWORD )_get_buffer (
1182 ( HANDLE )myFileChannel, cBuffer, ( DWORD )NByte,
1183 TRUE, myIO & FLAG_SOCKET
1186 if ( ( int )dwBytesRead == -1 ) { // an error occured
1188 _osd_wnt_set_error ( myError, OSD_WFile );
1192 } else if ( dwBytesRead == 0 ) { // connection closed - set end-of-file flag
1200 status = _get_line ( cBuffer, dwBytesRead );
1202 dwSeekPos = LODWORD( status );
1203 eos = ( Standard_CString )HIDWORD( status );
1206 if ( (__int64) status == (__int64) -1 ) { // last character in the buffer is <CR> -
1208 if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is <CR> -
1209 // peek next character to see if it is a <LF>
1212 NbyteRead = dwBytesRead; // (LD) always fits this case.
1214 dwDummy = _get_buffer (
1215 ( HANDLE )myFileChannel, ppeekChar, 1, TRUE, myIO & FLAG_SOCKET
1217 if ( ( int )dwDummy == -1 ) { // an error occured
1219 _osd_wnt_set_error ( myError, OSD_WFile );
1221 } else if ( dwDummy != 0 ) { // connection closed ?
1223 if ( peekChar == '\n' ) // we got a <CR><LF> sequence
1225 dwBytesRead++ ; // (LD) we have to jump <LF>
1232 if ( dwSeekPos != 0 )
1233 dwBytesRead = dwBytesRead + dwSeekPos;
1235 NbyteRead = ( Standard_Integer )( eos - cBuffer );
1239 // Don't rewrite datas in cBuffer.
1241 Standard_PCharacter cDummyBuffer = new Standard_Character[ NByte + 3 ];
1243 _get_buffer ( // remove pending input
1244 ( HANDLE )myFileChannel, cDummyBuffer, dwBytesRead, FALSE, myIO & FLAG_SOCKET
1246 delete [] cDummyBuffer ;
1252 RAISE( TEXT( "OSD_File :: ReadLine (): incorrect call - file is a directory" ) );
1254 if ( !Failed () && !IsAtEnd () )
1258 delete [] (Standard_PCharacter)cBuffer;
1260 } // end OSD_File :: ReadLine
1264 void OSD_File :: ReadLine (
1265 TCollection_AsciiString& Buffer,
1266 const Standard_Integer NByte, Standard_Integer& NbyteRead
1272 Standard_Character peekChar;
1273 Standard_CString cBuffer;
1274 Standard_CString eos;
1277 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
1278 Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
1282 TEST_RAISE( TEXT( "ReadLine" ) );
1284 if ( myIO & FLAG_PIPE && !( myIO & FLAG_READ_PIPE ) )
1286 RAISE( TEXT( "OSD_File :: ReadLine (): attempt to read from write only pipe" ) );
1288 // +----> leave space for end-of-string
1289 // | plus <CR><LF> sequence
1291 cBuffer = new Standard_Character[ NByte + 3 ];
1293 if ( myIO & FLAG_FILE ) {
1296 ( HANDLE )myFileChannel, cBuffer, ( DWORD )NByte, &dwBytesRead, NULL
1298 ) { // an error occured
1300 _osd_wnt_set_error ( myError, OSD_WFile );
1304 } else if ( dwBytesRead == 0 ) { // end-of-file reached
1312 status = _get_line ( cBuffer, dwBytesRead );
1314 dwSeekPos = LODWORD( status );
1315 eos = ( Standard_CString )HIDWORD( status );
1317 if ( (__int64) status == (__int64) -1 ) { // last character in the buffer is <CR> -
1319 if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is <CR> -
1320 // peek next character to see if it is a <LF>
1323 ( HANDLE )myFileChannel, &peekChar, 1, &dwDummy, NULL
1327 _osd_wnt_set_error ( myError, OSD_WFile );
1328 NbyteRead = dwBytesRead;
1330 } else if ( dwDummy != 0 ) { // end-of-file reached ?
1332 if ( peekChar == '\n' ) // we got a <CR><LF> sequence
1334 cBuffer[ --dwBytesRead ] = 0;
1336 else // adjust file position
1338 SetFilePointer ( ( HANDLE )myFileChannel, -1, NULL, FILE_CURRENT );
1344 NbyteRead = dwBytesRead;
1346 } else if ( dwSeekPos != 0 ) {
1348 SetFilePointer ( ( HANDLE )myFileChannel, ( LONG )dwSeekPos, NULL, FILE_CURRENT );
1349 NbyteRead = ( Standard_Integer )( eos - cBuffer );
1353 NbyteRead = eos - cBuffer;
1357 } else if ( myIO & FLAG_SOCKET || myIO & FLAG_PIPE || myIO & FLAG_NAMED_PIPE ) {
1359 dwBytesRead = ( DWORD )_get_buffer (
1360 ( HANDLE )myFileChannel, cBuffer, ( DWORD )NByte,
1361 TRUE, myIO & FLAG_SOCKET
1364 if ( ( int )dwBytesRead == -1 ) // an error occured
1366 _osd_wnt_set_error ( myError, OSD_WFile );
1368 else if ( dwBytesRead == 0 ) { // connection closed - set end-of-file flag
1376 status = _get_line ( cBuffer, dwBytesRead );
1378 dwSeekPos = LODWORD( status );
1379 eos = ( Standard_CString )HIDWORD( status );
1382 if ( (__int64) status == (__int64) -1 ) { // last character in the buffer is <CR> -
1384 if ( status == 0xFFFFFFFFFFFFFFFF ) { // last character in the buffer is <CR> -
1385 // peek next character to see if it is a <LF>
1387 dwDummy = _get_buffer (
1388 ( HANDLE )myFileChannel, &peekChar, 1, TRUE, myIO & FLAG_SOCKET
1390 eos = cBuffer + dwBytesRead;
1392 if ( ( int )dwDummy == -1 ) { // an error occured
1394 _osd_wnt_set_error ( myError, OSD_WFile );
1395 NbyteRead = dwBytesRead;
1397 } else if ( dwDummy != 0 ) { // connection closed ?
1399 if ( peekChar == '\n' ) // we got a <CR><LF> sequence
1401 cBuffer[ dwBytesRead - 1 ] = 0, eos = cBuffer + ( dwBytesRead++ - 1 );
1407 NbyteRead = dwBytesRead;
1409 } else if ( dwSeekPos != 0 ) {
1411 dwBytesRead = dwBytesRead + dwSeekPos;
1412 NbyteRead = ( Standard_Integer )( eos - cBuffer );
1416 NbyteRead = ( Standard_Integer )( eos - cBuffer );
1418 _get_buffer ( // remove pending input
1419 ( HANDLE )myFileChannel, cBuffer, dwBytesRead, FALSE, myIO & FLAG_SOCKET
1427 RAISE( TEXT( "OSD_File :: ReadLine (): incorrect call - file is a directory" ) );
1429 if ( !Failed () && !IsAtEnd () )
1435 } // end OSD_File :: ReadLine
1439 // --------------------------------------------------------------------------
1440 // Read content of a file
1441 // --------------------------------------------------------------------------
1443 void OSD_File :: Read (
1444 Standard_Address& Buffer,
1445 const Standard_Integer Nbyte, Standard_Integer& Readbyte
1450 if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) {
1451 Standard_ProgramError::Raise("OSD_File::Read : it is a directory");
1454 TEST_RAISE( TEXT( "Read" ) );
1456 if ( myIO & FLAG_PIPE && !( myIO & FLAG_READ_PIPE ) )
1458 RAISE( TEXT( "OSD_File :: Read (): attempt to read from write only pipe" ) );
1461 ( HANDLE )myFileChannel, Buffer, ( DWORD )Nbyte, &dwBytesRead, NULL
1465 _osd_wnt_set_error ( myError, OSD_WFile );
1468 } else if ( dwBytesRead == 0 )
1476 Readbyte = ( Standard_Integer )dwBytesRead;
1478 } // end OSD_File :: Read
1480 void OSD_File :: Write (
1481 const TCollection_AsciiString& Buffer,
1482 const Standard_Integer Nbyte
1485 Write ( ( Standard_Address )Buffer.ToCString (), Nbyte );
1487 } // end OSD_File :: Write
1489 // --------------------------------------------------------------------------
1490 // Write content of a file
1491 // --------------------------------------------------------------------------
1493 void OSD_File :: Write (
1494 const Standard_Address Buffer,
1495 const Standard_Integer Nbyte
1498 DWORD dwBytesWritten;
1500 TEST_RAISE( TEXT( "Write" ) );
1502 if ( myIO & FLAG_PIPE && myIO & FLAG_READ_PIPE )
1504 RAISE( TEXT( "OSD_File :: Write (): attempt to write to read only pipe" ) );
1507 ( HANDLE )myFileChannel, Buffer, ( DWORD )Nbyte, &dwBytesWritten, NULL
1508 ) || dwBytesWritten != ( DWORD )Nbyte
1511 _osd_wnt_set_error ( myError, OSD_WFile );
1513 } // end OSD_File :: Write
1515 void OSD_File :: Seek (
1516 const Standard_Integer Offset, const OSD_FromWhere Whence
1521 TEST_RAISE( TEXT( "Seek" ) );
1523 if ( myIO & FLAG_FILE || myIO & FLAG_DIRECTORY ) {
1527 case OSD_FromBeginning:
1529 dwMoveMethod = FILE_BEGIN;
1535 dwMoveMethod = FILE_CURRENT;
1541 dwMoveMethod = FILE_END;
1547 RAISE( TEXT( "OSD_File :: Seek (): invalid parameter" ) );
1551 if ( SetFilePointer (
1552 ( HANDLE )myFileChannel, ( LONG )Offset, NULL, dwMoveMethod
1556 _osd_wnt_set_error ( myError, OSD_WFile );
1562 } // end OSD_File :: Seek
1564 // --------------------------------------------------------------------------
1566 // --------------------------------------------------------------------------
1568 void OSD_File :: Close () {
1570 TEST_RAISE( TEXT( "Close" ) );
1572 CloseHandle ( ( HANDLE )myFileChannel );
1574 myFileChannel = ( Standard_Integer )INVALID_HANDLE_VALUE;
1577 } // end OSD_File :: Close
1579 // --------------------------------------------------------------------------
1580 // Test if at end of file
1581 // --------------------------------------------------------------------------
1583 Standard_Boolean OSD_File :: IsAtEnd () {
1585 TEST_RAISE( TEXT( "IsAtEnd" ) );
1587 if (myIO & FLAG_EOF)
1588 return Standard_True ;
1589 return Standard_False ;
1591 } // end OSD_File :: IsAtEnd
1593 OSD_KindFile OSD_File :: KindOfFile () const {
1595 OSD_KindFile retVal;
1596 Standard_Integer flags;
1598 if ( ( HANDLE )myFileChannel == INVALID_HANDLE_VALUE ) {
1600 TCollection_AsciiString fName;
1602 myPath.SystemName ( fName );
1604 if ( fName.IsEmpty () )
1606 RAISE( TEXT( "OSD_File :: KindOfFile (): incorrent call - no filename given" ) );
1608 flags = _get_file_type (
1609 fName.ToCString (), ( Standard_Integer )INVALID_HANDLE_VALUE
1616 switch ( flags & FLAG_TYPE ) {
1624 case FLAG_DIRECTORY:
1626 retVal = OSD_DIRECTORY;
1632 retVal = OSD_SOCKET;
1638 retVal = OSD_UNKNOWN;
1644 } // end OSD_File :: KindOfFile
1648 OSD_File OSD_File :: BuildTemporary () {
1654 char tmpbuf [MAX_PATH];
1655 if (GetTempPath (MAX_PATH, tmpbuf) == 0)
1657 perror ("ERROR in GetTempPath");
1660 char tmpbuf2 [MAX_PATH];
1661 if (GetTempFileName (tmpbuf, NULL, 0, tmpbuf2) == 0)
1663 perror ("ERROR in GetTempFileName");
1666 TCollection_AsciiString fileName ( tmpbuf2 );
1668 TCollection_AsciiString fileName ( _ttmpnam ( NULL ) );
1671 OSD_Path filePath ( fileName );
1673 retVal.SetPath ( filePath );
1674 retVal.Build ( OSD_ReadWrite, prt );
1678 } // end OSD_File :: BuildTemporary
1682 //-------------------------------------------------debutpri???980424
1684 typedef struct _osd_wnt_key {
1692 OSD_File OSD_File :: BuildTemporary () {
1697 TCHAR tmpPath[ MAX_PATH ];
1699 OSD_WNT_KEY regKey[ 2 ] = {
1701 { HKEY_LOCAL_MACHINE,
1702 TEXT( "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" )
1705 TEXT( ".DEFAULT\\Environment" )
1710 for ( int i = 0; i < 2; ++i ) {
1713 regKey[ i ].hKey, regKey[ i ].keyPath, 0, KEY_QUERY_VALUE, &hKey
1720 if ( RegQueryValueEx (
1721 hKey, TEXT( "TEMP" ), NULL, &dwType, NULL, &dwSize
1725 LPTSTR kVal = ( LPTSTR )HeapAlloc (
1726 GetProcessHeap (), HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS,
1727 dwSize + sizeof ( TCHAR )
1730 RegQueryValueEx ( hKey, TEXT( "TEMP" ), NULL, &dwType, ( LPBYTE )kVal, &dwSize );
1732 if ( dwType == REG_EXPAND_SZ )
1734 ExpandEnvironmentStrings ( kVal, tmpPath, MAX_PATH );
1738 lstrcpy ( tmpPath, kVal );
1740 HeapFree ( GetProcessHeap (), 0, ( LPVOID )kVal );
1745 RegCloseKey ( hKey );
1753 if ( !fOK ) lstrcpy ( tmpPath, TEXT( "./" ) );
1755 GetTempFileName ( tmpPath, "CSF", 0, tmpPath );
1757 retVal.SetPath ( OSD_Path ( tmpPath ) );
1758 retVal.Build ( OSD_ReadWrite, prt );
1762 } // end OSD_File :: BuildTemporary
1766 //-------------------------------------------------finpri???980424
1768 #if defined(__CYGWIN32__) || defined(__MINGW32__)
1771 #define __leave return
1774 void OSD_File :: SetLock ( const OSD_LockType Lock ) {
1779 TEST_RAISE( TEXT( "SetLock" ) );
1781 ZeroMemory ( &ovlp, sizeof ( OVERLAPPED ) );
1785 if ( ( myLock = Lock ) == OSD_NoLock ) {
1790 } else if ( myLock == OSD_ReadLock || myLock == OSD_ExclusiveLock ) {
1792 dwFlags = LOCKFILE_EXCLUSIVE_LOCK;
1799 ( HANDLE )myFileChannel, dwFlags, 0, Size (), 0, &ovlp
1803 _osd_wnt_set_error ( myError, OSD_WFile );
1808 ImperativeFlag = Standard_True;
1815 leave: ; // added for VisualAge
1817 } // end OSD_File :: SetLock
1819 #if defined(__CYGWIN32__) || defined(__MINGW32__)
1825 void OSD_File :: UnLock () {
1827 TEST_RAISE( TEXT( "Unlock" ) );
1829 if ( ImperativeFlag ) {
1832 ( HANDLE )myFileChannel, 0, 0, Size (), 0
1836 _osd_wnt_set_error ( myError, OSD_WFile );
1838 ImperativeFlag = Standard_False;
1842 } // end OSD_File :: UnLock
1844 OSD_LockType OSD_File :: GetLock () {
1848 } // end OSD_File :: GetLock
1850 Standard_Boolean OSD_File :: IsLocked () {
1852 TEST_RAISE( TEXT( "IsLocked" ) );
1854 return ImperativeFlag;
1856 } // end OSD_File :: IsLocked
1859 // --------------------------------------------------------------------------
1860 // Return size of a file
1861 // --------------------------------------------------------------------------
1863 Standard_Integer OSD_File :: Size () {
1865 Standard_Integer retVal;
1867 TEST_RAISE( TEXT( "Size" ) );
1869 retVal = ( Standard_Integer )GetFileSize (
1870 ( HANDLE )myFileChannel, NULL
1873 if ( retVal == ( Standard_Integer )0xFFFFFFFF )
1875 _osd_wnt_set_error ( myError, OSD_WFile );
1879 } // end OSD_File :: Size
1881 // --------------------------------------------------------------------------
1882 // Print contains of a file
1883 // --------------------------------------------------------------------------
1885 void OSD_File :: Print ( const OSD_Printer& WhichPrinter ) {
1887 if ( ( HANDLE )myFileChannel != INVALID_HANDLE_VALUE )
1889 RAISE( TEXT( "OSD_File :: Print (): incorrect call - file opened" ) );
1891 TCollection_AsciiString pName, fName;
1893 WhichPrinter.Name ( pName );
1894 myPath.SystemName ( fName );
1896 if ( !_osd_print ( (Standard_PCharacter)pName.ToCString (), fName.ToCString () ) )
1898 _osd_wnt_set_error ( myError, OSD_WFile );
1900 } // end OSD_File :: Print
1902 // --------------------------------------------------------------------------
1903 // Test if a file is open
1904 // --------------------------------------------------------------------------
1906 Standard_Boolean OSD_File :: IsOpen () const {
1908 return ( HANDLE )myFileChannel != INVALID_HANDLE_VALUE;
1910 } // end OSD_File :: IsOpen
1912 #if defined(__CYGWIN32__) || defined(__MINGW32__)
1915 #define __leave return retVal
1918 PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd (
1919 const OSD_Protection& prot, BOOL fDir, char* fName
1925 HANDLE hProcess = NULL;
1930 DWORD dwAccessAdmin;
1931 DWORD dwAccessGroup;
1932 DWORD dwAccessOwner;
1933 DWORD dwAccessWorld;
1934 DWORD dwAccessAdminDir;
1935 DWORD dwAccessGroupDir;
1936 DWORD dwAccessOwnerDir;
1937 DWORD dwAccessWorldDir;
1938 DWORD dwACLsize = sizeof ( ACL );
1940 PTOKEN_OWNER pTkOwner = NULL;
1941 PTOKEN_GROUPS pTkGroups = NULL;
1942 PTOKEN_PRIMARY_GROUP pTkPrimaryGroup = NULL;
1943 PSECURITY_DESCRIPTOR retVal;
1944 PSECURITY_DESCRIPTOR pfSD = NULL;
1952 if ( !OpenProcessToken (
1953 GetCurrentProcess (), TOKEN_QUERY, &hProcess
1957 if ( ( pTkGroups = ( PTOKEN_GROUPS )GetTokenInformationEx (
1958 hProcess, TokenGroups
1963 if ( ( pTkOwner = ( PTOKEN_OWNER )GetTokenInformationEx (
1964 hProcess, TokenOwner
1969 if ( ( pTkPrimaryGroup = ( PTOKEN_PRIMARY_GROUP )GetTokenInformationEx (
1970 hProcess, TokenPrimaryGroup
1977 if ( fName == NULL )
1979 pSIDowner = pTkOwner -> Owner;
1983 pfSD = GetFileSecurityEx ( fName, OWNER_SECURITY_INFORMATION );
1985 if ( pfSD == NULL || !GetSecurityDescriptorOwner ( pfSD, &pSIDowner, &fDummy ) ) {
1994 pSIDadmin = AdminSid ();
1995 pSIDworld = WorldSid ();
1997 dwAccessAdmin = _get_access_mask ( prot.System () );
1998 dwAccessGroup = _get_access_mask ( prot.Group () );
1999 dwAccessOwner = _get_access_mask ( prot.User () );
2000 dwAccessWorld = _get_access_mask ( prot.World () );
2002 dwAccessAdminDir = _get_dir_access_mask ( prot.System () );
2003 dwAccessGroupDir = _get_dir_access_mask ( prot.Group () );
2004 dwAccessOwnerDir = _get_dir_access_mask ( prot.User () );
2005 dwAccessWorldDir = _get_dir_access_mask ( prot.World () );
2007 if ( dwAccessGroup != 0 ) {
2009 for ( i = 0; i < ( int )pTkGroups -> GroupCount; ++i ) {
2011 pSIDtemp = pTkGroups -> Groups[ i ].Sid;
2013 if ( !NtPredefinedSid ( pSIDtemp ) &&
2014 !EqualSid ( pSIDtemp, pSIDworld ) &&
2015 !EqualSid ( pSIDtemp, pTkPrimaryGroup -> PrimaryGroup ) &&
2016 IsValidSid ( pSIDtemp )
2019 dwACLsize += ( ( GetLengthSid ( pSIDtemp ) + ACE_HEADER_SIZE ) << j );
2025 dwACLsize += ( ( ( GetLengthSid ( pSIDowner ) + ACE_HEADER_SIZE ) << j ) +
2026 ( ( GetLengthSid ( pSIDadmin ) + ACE_HEADER_SIZE ) << j ) +
2027 ( ( GetLengthSid ( pSIDworld ) + ACE_HEADER_SIZE ) << j )
2030 if ( ( pACL = CreateAcl ( dwACLsize ) ) == NULL ) __leave;
2032 if ( dwAccessAdmin != 0 )
2034 if ( ( pFileACE = ( PFILE_ACE )AllocAccessAllowedAce (
2041 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2045 pFileACE -> dwMask = dwAccessAdminDir;
2046 pFileACE -> header.AceFlags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE;
2047 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2051 FreeAce ( pFileACE );
2055 if ( dwAccessOwner != 0 )
2057 if ( ( pFileACE = ( PFILE_ACE )AllocAccessAllowedAce (
2058 dwAccessOwner, 0, pSIDowner
2063 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2067 pFileACE -> dwMask = dwAccessOwnerDir;
2068 pFileACE -> header.AceFlags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE;
2069 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2073 FreeAce ( pFileACE );
2077 if ( dwAccessWorld != 0 )
2079 if ( ( pFileACE = ( PFILE_ACE )AllocAccessAllowedAce (
2080 dwAccessWorld, 0, pSIDworld
2085 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2089 pFileACE -> header.AceFlags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE;
2090 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2094 FreeAce ( pFileACE );
2098 if ( dwAccessGroup != 0 ) {
2100 for ( i = 0; i < ( int )pTkGroups -> GroupCount; ++i ) {
2102 pSIDtemp = pTkGroups -> Groups[ i ].Sid;
2104 if ( !NtPredefinedSid ( pSIDtemp ) &&
2105 !EqualSid ( pSIDtemp, pSIDworld ) &&
2106 !EqualSid ( pSIDtemp, pTkPrimaryGroup -> PrimaryGroup ) &&
2107 IsValidSid ( pSIDtemp )
2110 if ( dwAccessGroup != 0 )
2112 if ( ( pFileACE = ( PFILE_ACE )AllocAccessAllowedAce (
2113 dwAccessGroup, 0, pSIDtemp
2118 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2122 pFileACE -> header.AceFlags = OBJECT_INHERIT_ACE | CONTAINER_INHERIT_ACE | INHERIT_ONLY_ACE;
2123 AddAce ( pACL, ACL_REVISION, dwIndex++, pFileACE, pFileACE -> header.AceSize );
2127 FreeAce ( pFileACE );
2137 if ( ( retVal = AllocSD () ) == NULL ) __leave;
2139 if ( !SetSecurityDescriptorDacl ( retVal, TRUE, pACL, TRUE ) ) __leave;
2149 if ( retVal != NULL )
2153 else if ( pACL != NULL )
2161 if ( hProcess != NULL ) CloseHandle ( hProcess );
2162 if ( pTkOwner != NULL ) FreeTokenInformation ( pTkOwner );
2163 if ( pTkGroups != NULL ) FreeTokenInformation ( pTkGroups );
2164 if ( pTkPrimaryGroup != NULL ) FreeTokenInformation ( pTkPrimaryGroup );
2165 if ( pfSD != NULL ) FreeFileSecurity ( pfSD );
2170 leave: ; // added for VisualAge
2175 } // end _osd_wnt_protection_to_sd */
2177 #if defined(__CYGWIN32__) || defined(__MINGW32__)
2183 static void __fastcall _test_raise ( Standard_Integer hFile, Standard_CString str ) {
2185 Standard_Character buff[ 64 ];
2187 if ( ( HANDLE )hFile == INVALID_HANDLE_VALUE ) {
2189 _tcscpy ( buff, TEXT( "OSD_File :: " ) );
2190 _tcscat ( buff, str );
2191 _tcscat ( buff, TEXT( " (): wrong access" ) );
2193 Standard_ProgramError :: Raise ( buff );
2197 } // end _test_raise
2201 // Modified so that we have <nl> at end of line if we have read <nl> or <cr>
2202 // by LD 17 dec 98 for B4.4
2204 static DWORDLONG __fastcall _get_line ( Standard_PCharacter& buffer, DWORD dwBuffSize ) {
2207 Standard_PCharacter ptr;
2209 buffer[ dwBuffSize ] = 0;
2212 while ( *ptr != 0 ) {
2214 if ( *ptr == TEXT( '\n' ) ) {
2216 ptr++ ; // jump newline char.
2218 retVal = ptr - buffer - dwBuffSize;
2219 retVal &= 0x0000000FFFFFFFF;// import 32-bit to 64-bit
2221 retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) );
2223 retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 );
2227 } else if ( *ptr == TEXT( '\r' ) && ptr[ 1 ] == TEXT( '\n' ) ) {
2229 *(ptr++) = '\n' ; // Substitue carriage return by newline.
2231 retVal = ptr + 1 - buffer - dwBuffSize;
2232 retVal &= 0x0000000FFFFFFFF;// import 32-bit to 64-bit
2234 retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) );
2236 retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 );
2240 } else if ( *ptr == TEXT( '\r' ) && ptr[ 1 ] == 0 ) {
2241 *ptr = '\n' ; // Substitue carriage return by newline
2244 return (DWORDLONG) (__int64) (-1);
2246 return 0xFFFFFFFFFFFFFFFF;
2254 retVal = (DWORDLONG) ( ( (unsigned __int64) ((DWORD) buffer + dwBuffSize) ) << 32 );
2255 retVal = (DWORDLONG) ( (unsigned __int64) retVal & (((unsigned __int64) 0xFFFFFFFF) << 32) );
2257 retVal = ( ( ( DWORDLONG )( ( DWORD )buffer + dwBuffSize ) ) << 32 );
2258 retVal &= 0xFFFFFFFF00000000;
2267 static DWORDLONG __fastcall _get_line ( Standard_CString buffer, DWORD dwBuffSize ) {
2270 Standard_CString ptr;
2272 buffer[ dwBuffSize ] = 0;
2275 while ( *ptr != 0 ) {
2277 if ( *ptr == TEXT( '\n' ) ) {
2279 retVal = buffer - ptr;
2281 buffer[ (__int64) -( LONGLONG )retVal ] = 0;
2283 buffer[ -( LONGLONG )retVal ] = 0;
2285 retVal = ptr + 1 - buffer - dwBuffSize;
2287 retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) );
2289 retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 );
2293 } else if ( *ptr == TEXT( '\r' ) && ptr[ 1 ] == TEXT( '\n' ) ) {
2295 retVal = buffer - ptr;
2297 buffer[ (__int64) -( LONGLONG )retVal ] = 0;
2299 buffer[ -( LONGLONG )retVal ] = 0;
2301 retVal = ptr + 2 - buffer - dwBuffSize;
2303 retVal = (DWORDLONG) ( (unsigned __int64) retVal | (((unsigned __int64) ptr) << 32) );
2305 retVal |= ( ( ( DWORDLONG )( DWORD )ptr ) << 32 );
2309 } else if ( *ptr == TEXT( '\r' ) && ptr[ 1 ] == 0 )
2312 return (DWORDLONG) (__int64) (-1);
2314 return 0xFFFFFFFFFFFFFFFF;
2322 retVal = (DWORDLONG) ( ( (unsigned __int64) ((DWORD) buffer + dwBuffSize) ) << 32 );
2323 retVal = (DWORDLONG) ( (unsigned __int64) retVal & (((unsigned __int64) 0xFFFFFFFF) << 32) );
2325 retVal = ( ( ( DWORDLONG )( ( DWORD )buffer + dwBuffSize ) ) << 32 );
2326 retVal &= 0xFFFFFFFF00000000;
2335 static int __fastcall _get_buffer (
2337 Standard_PCharacter& buffer,
2339 BOOL fPeek, BOOL fSocket
2349 flags = fPeek ? MSG_PEEK : 0;
2351 retVal = recv ( ( SOCKET )hChannel, buffer, ( int )dwSize, flags );
2353 if ( retVal == SOCKET_ERROR ) retVal = -1;
2359 if ( !PeekNamedPipe (
2360 hChannel, buffer, dwSize, &dwBytesRead, &dwDummy, &dwDummy
2361 ) && GetLastError () != ERROR_BROKEN_PIPE
2368 retVal = ( int )dwBytesRead;
2372 if ( !ReadFile ( hChannel, buffer, dwSize, &dwBytesRead, NULL ) )
2378 retVal = ( int )dwBytesRead;
2386 } // end _get_buffer
2389 static DWORD __fastcall _get_access_mask ( OSD_SingleProtection prt ) {
2403 retVal = FILE_GENERIC_READ;
2409 retVal = FILE_GENERIC_WRITE;
2415 retVal = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
2421 retVal = FILE_GENERIC_EXECUTE;
2427 retVal = FILE_GENERIC_READ | FILE_GENERIC_EXECUTE;
2433 retVal = FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE;
2439 retVal = FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE;
2451 retVal = FILE_GENERIC_READ | DELETE;
2457 retVal = FILE_GENERIC_WRITE | DELETE;
2463 retVal = FILE_GENERIC_READ | FILE_GENERIC_WRITE | DELETE;
2469 retVal = FILE_GENERIC_EXECUTE | DELETE;
2475 retVal = FILE_GENERIC_READ | FILE_GENERIC_EXECUTE | DELETE;
2481 retVal = FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE | DELETE;
2487 retVal = FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE | DELETE;
2493 RAISE( TEXT( "_get_access_mask (): incorrect parameter" ) );
2499 } // end _get_access_mask
2501 static DWORD __fastcall _get_dir_access_mask ( OSD_SingleProtection prt ) {
2515 retVal = GENERIC_READ;
2521 retVal = GENERIC_WRITE;
2527 retVal = GENERIC_READ | GENERIC_WRITE;
2533 retVal = GENERIC_EXECUTE;
2539 retVal = GENERIC_READ | GENERIC_EXECUTE;
2545 retVal = GENERIC_WRITE | GENERIC_EXECUTE;
2551 retVal = GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE;
2563 retVal = GENERIC_READ | DELETE;
2569 retVal = GENERIC_WRITE | DELETE;
2575 retVal = GENERIC_READ | GENERIC_WRITE | DELETE;
2581 retVal = GENERIC_EXECUTE | DELETE;
2587 retVal = GENERIC_READ | GENERIC_EXECUTE | DELETE;
2593 retVal = GENERIC_WRITE | GENERIC_EXECUTE | DELETE;
2599 retVal = GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | DELETE;
2605 RAISE( TEXT( "_get_dir_access_mask (): incorrect parameter" ) );
2611 } // end _get_dir_access_mask
2613 static HANDLE __fastcall _open_file (
2614 Standard_CString fName,
2616 DWORD dwOptions, LPBOOL fNew
2619 HANDLE retVal = INVALID_HANDLE_VALUE;
2620 DWORD dwDesiredAccess;
2621 DWORD dwCreationDistribution;
2627 dwDesiredAccess = GENERIC_READ;
2633 dwDesiredAccess = GENERIC_WRITE;
2639 dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
2645 RAISE( TEXT( "_open_file (): incorrect parameter" ) );
2649 dwCreationDistribution = ( dwOptions != OPEN_NEW ) ? OPEN_EXISTING : CREATE_ALWAYS;
2651 retVal = CreateFile (
2652 fName, dwDesiredAccess,
2653 FILE_SHARE_READ | FILE_SHARE_WRITE,
2654 NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
2657 if ( retVal == INVALID_HANDLE_VALUE &&
2658 dwOptions == OPEN_APPEND &&
2659 GetLastError () == ERROR_FILE_NOT_FOUND
2663 dwCreationDistribution = CREATE_ALWAYS;
2665 retVal = CreateFile (
2666 fName, dwDesiredAccess,
2667 FILE_SHARE_READ | FILE_SHARE_WRITE,
2668 NULL, dwCreationDistribution, FILE_ATTRIBUTE_NORMAL, NULL
2679 Standard_Integer __fastcall _get_file_type (
2680 Standard_CString fName, Standard_Integer fileHandle
2683 Standard_Integer retVal;
2687 fileType = fileHandle == ( Standard_Integer )INVALID_HANDLE_VALUE ?
2689 GetFileType ( ( HANDLE )fileHandle );
2691 switch ( fileType ) {
2693 case FILE_TYPE_UNKNOWN:
2695 retVal = FLAG_SOCKET;
2699 case FILE_TYPE_DISK:
2701 if ( ( dwType = GetFileAttributes ( fName ) ) != 0xFFFFFFFF )
2703 retVal = dwType & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
2707 retVal = 0x80000000;
2711 case FILE_TYPE_CHAR:
2713 retVal = FLAG_DEVICE;
2717 case FILE_TYPE_PIPE:
2727 } // end _get_file_type
2729 #if defined(__CYGWIN32__) || defined(__MINGW32__)
2732 #define __leave return retVal
2735 BOOL __fastcall _osd_wnt_sd_to_protection (
2736 PSECURITY_DESCRIPTOR pSD, OSD_Protection& prot, BOOL fDir
2747 DWORD dwAccessOwner = 0;
2748 DWORD dwAccessGroup = 0;
2749 DWORD dwAccessAdmin = 0;
2750 DWORD dwAccessWorld = 0;
2751 BOOL retVal = FALSE;
2752 GET_PROT_FUNC _get_prot_func = fDir ? &_get_protection_dir : &_get_protection;
2756 if ( !GetSecurityDescriptorOwner ( pSD, &pSIDowner, &fDefaulted ) ) __leave;
2758 if ( !GetSecurityDescriptorDacl ( pSD, &fPresent, &pACL, &fDefaulted ) ||
2762 if ( pSIDowner == NULL || pACL == NULL ) {
2764 SetLastError ( ERROR_NO_SECURITY_ON_OBJECT );
2769 pSIDadmin = AdminSid ();
2770 pSIDworld = WorldSid ();
2772 for ( i = 0; i < ( int )pACL -> AceCount; ++i ) {
2774 if ( GetAce ( pACL, i, &pACE ) ) {
2776 if ( EqualSid ( pSIDowner, GET_SID( pACE ) ) )
2778 dwAccessOwner = ( ( PACE_HEADER )pACE ) -> AceType == ACCESS_DENIED_ACE_TYPE ?
2779 0 : *GET_MSK( pACE );
2781 else if ( EqualSid ( pSIDadmin, GET_SID( pACE ) ) )
2783 dwAccessAdmin = ( ( PACE_HEADER )pACE ) -> AceType == ACCESS_DENIED_ACE_TYPE ?
2784 0 : *GET_MSK( pACE );
2786 else if ( EqualSid ( pSIDworld, GET_SID( pACE ) ) )
2788 dwAccessWorld = ( ( PACE_HEADER )pACE ) -> AceType == ACCESS_DENIED_ACE_TYPE ?
2789 0 : *GET_MSK( pACE );
2793 dwAccessGroup = ( ( PACE_HEADER )pACE ) -> AceType == ACCESS_DENIED_ACE_TYPE ?
2794 0 : *GET_MSK( pACE );
2801 ( *_get_prot_func ) ( dwAccessAdmin ),
2802 ( *_get_prot_func ) ( dwAccessOwner ),
2803 ( *_get_prot_func ) ( dwAccessGroup ),
2804 ( *_get_prot_func ) ( dwAccessWorld )
2814 leave: ; // added for VisualAge
2819 } // end _osd_wnt_sd_to_protection
2821 #if defined(__CYGWIN32__) || defined(__MINGW32__)
2827 static OSD_SingleProtection __fastcall _get_protection ( DWORD mask ) {
2829 OSD_SingleProtection retVal;
2833 case FILE_GENERIC_READ:
2839 case FILE_GENERIC_WRITE:
2845 case FILE_GENERIC_READ | FILE_GENERIC_WRITE:
2851 case FILE_GENERIC_EXECUTE:
2857 case FILE_GENERIC_READ | FILE_GENERIC_EXECUTE:
2863 case FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE:
2869 case FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE:
2881 case FILE_GENERIC_READ | DELETE:
2887 case FILE_GENERIC_WRITE | DELETE:
2893 case FILE_GENERIC_READ | FILE_GENERIC_WRITE | DELETE:
2899 case FILE_GENERIC_EXECUTE | DELETE:
2905 case FILE_GENERIC_READ | FILE_GENERIC_EXECUTE | DELETE:
2911 case FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE | DELETE:
2917 case FILE_ALL_ACCESS:
2918 case FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE | DELETE:
2933 } // end _get_protection
2935 static OSD_SingleProtection __fastcall _get_protection_dir ( DWORD mask ) {
2937 OSD_SingleProtection retVal;
2953 case GENERIC_READ | GENERIC_WRITE:
2959 case GENERIC_EXECUTE:
2965 case GENERIC_READ | GENERIC_EXECUTE:
2971 case GENERIC_WRITE | GENERIC_EXECUTE:
2977 case GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE:
2989 case GENERIC_READ | DELETE:
2995 case GENERIC_WRITE | DELETE:
3001 case GENERIC_READ | GENERIC_WRITE | DELETE:
3007 case GENERIC_EXECUTE | DELETE:
3013 case GENERIC_READ | GENERIC_EXECUTE | DELETE:
3019 case GENERIC_WRITE | GENERIC_EXECUTE | DELETE:
3025 case FILE_ALL_ACCESS:
3026 case GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE | DELETE:
3041 } // end _get_protection_dir
3043 #if defined(__CYGWIN32__) || defined(__MINGW32__)
3046 #define __leave return fOK
3049 BOOL __fastcall _osd_print (const Standard_PCharacter pName, Standard_CString fName ) {
3053 BYTE jobInfo[ MAX_PATH + sizeof ( DWORD ) ];
3054 DWORD dwNeeded, dwCode;
3060 if ( !OpenPrinter ( Standard_PCharacter(pName), &hPrinter, NULL ) ) {
3068 hPrinter, 1, jobInfo, MAX_PATH + sizeof ( DWORD ), &dwNeeded
3075 fName, ( ( ADDJOB_INFO_1* )jobInfo ) -> Path, FALSE
3080 hPrinter, ( ( ADDJOB_INFO_1* )jobInfo ) -> JobId
3093 DWORD dwBytesNeeded;
3095 dwCode = GetLastError ();
3097 if ( fJob && hPrinter != NULL ) {
3100 hPrinter, ( ( ADDJOB_INFO_1* )jobInfo ) -> JobId, 1,
3101 info, 1024, &dwBytesNeeded
3104 if ( fJob ) SetJob (
3106 ( ( ADDJOB_INFO_1* )jobInfo ) -> JobId,
3107 1, info, JOB_CONTROL_CANCEL
3114 if ( hPrinter != NULL ) ClosePrinter ( hPrinter );
3119 leave: ; // added for VisualAge
3122 if ( !fOK ) SetLastError ( dwCode );
3128 #if defined(__CYGWIN32__) || defined(__MINGW32__)
3134 Standard_Boolean OSD_File::IsReadable()
3136 TCollection_AsciiString FileName ;
3139 myPath.SystemName(FileName) ;
3140 Channel = _open_file(FileName.ToCString(), OSD_ReadOnly, OPEN_OLD) ;
3141 if (Channel == INVALID_HANDLE_VALUE)
3142 return Standard_False ;
3144 CloseHandle (Channel) ;
3145 return Standard_True ;
3150 Standard_Boolean OSD_File::IsWriteable()
3152 TCollection_AsciiString FileName ;
3155 myPath.SystemName(FileName) ;
3156 Channel = _open_file(FileName.ToCString(), OSD_ReadWrite, OPEN_OLD) ;
3157 if (Channel == INVALID_HANDLE_VALUE)
3158 return Standard_False ;
3160 CloseHandle (Channel) ;
3161 return Standard_True ;
3165 Standard_Boolean OSD_File::IsExecutable()
3167 return IsReadable() ;
3169 // if (_access(FileName.ToCString(),0))
3175 // ---------------------------------------------------------------------
3176 // Read lines in a file while it is increasing.
3177 // Each line is terminated with a <nl>.
3178 // ---------------------------------------------------------------------
3182 Standard_Boolean OSD_File::ReadLastLine(TCollection_AsciiString& aLine,const Standard_Integer aDelay,const Standard_Integer aNbTries)
3184 static Standard_Integer MaxLength = 1000 ;
3185 Standard_Integer Len ;
3186 Standard_Integer Count = aNbTries ;
3189 return Standard_False ;
3191 ReadLine(aLine, MaxLength, Len) ;
3192 if (!aLine.IsEmpty())
3193 return Standard_True ;
3195 return Standard_False ;
3196 OSD::SecSleep(aDelay) ;
3201 Standard_Boolean OSD_File::Edit()
3203 cout << "Function OSD_File::Edit() not yet implemented." << endl;
3204 return Standard_False ;