1 // Copyright (c) 2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
18 #include <OSD_OpenFile.hxx>
20 #include <sys/types.h>
23 // ==============================================
24 // function : OSD_OpenFile
25 // purpose : Opens file
26 // ==============================================
27 FILE* OSD_OpenFile(const char* theName,
32 // file name is treated as UTF-8 string and converted to UTF-16 one
33 const TCollection_ExtendedString aFileNameW (theName, Standard_True);
34 const TCollection_ExtendedString aFileModeW (theMode, Standard_True);
35 aFile = ::_wfopen (aFileNameW.ToWideString(),
36 aFileModeW.ToWideString());
38 aFile = ::fopen (theName, theMode);
43 // ==============================================
44 // function : OSD_OpenFile
45 // purpose : Opens file
46 // ==============================================
47 FILE* OSD_OpenFile(const TCollection_ExtendedString& theName,
52 const TCollection_ExtendedString aFileModeW (theMode, Standard_True);
53 aFile = ::_wfopen (theName.ToWideString(),
54 aFileModeW.ToWideString());
56 // conversion in UTF-8 for linux
57 NCollection_Utf8String aString (theName.ToExtString());
58 aFile = ::fopen (aString.ToCString(),theMode);
63 // ==============================================
64 // function : OSD_FileStatCTime
66 // ==============================================
67 Standard_Time OSD_FileStatCTime (const char* theName)
69 Standard_Time aTime = 0;
71 // file name is treated as UTF-8 string and converted to UTF-16 one
72 const TCollection_ExtendedString aFileNameW (theName, Standard_True);
73 struct __stat64 aStat;
74 if (_wstat64 (aFileNameW.ToWideString(), &aStat) == 0)
76 aTime = (Standard_Time )aStat.st_ctime;
80 if (stat (theName, &aStat) == 0)
82 aTime = (Standard_Time )aStat.st_ctime;