xref: /aoo41x/main/tools/workben/fstest.cxx (revision 89b56da7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_tools.hxx"
26 
27 #define _FSTEST_CXX "$Revision: 1.5 $"
28 #include <tools/solar.h>
29 
30 #include <stdio.h>
31 #include <tools/stream.hxx>
32 #include <tools/fsys.hxx>
33 #include <tools/date.hxx>
34 #include <tools/time.hxx>
35 
36 void CheckTimes(DirEntry aDE);
37 
38 /*
39  * main.
40  */
main(int argc,char ** argv)41 int main (int argc, char **argv)
42 {
43 	DirEntry aDir;
44 	if (aDir.Exists())
45 	{
46 		aDir.ToAbs();
47 		String sTmp(aDir.GetFull(FSYS_STYLE_HOST));
48 		printf("Directory = %s\n", sTmp.GetStr());
49 		CheckTimes(aDir);
50 		DirEntry aFile =
51 			aDir + DirEntry("testfile.txt", FSYS_STYLE_HOST);
52 		SvFileStream aStream;
53 		aStream.Open(aFile.GetFull(FSYS_STYLE_HOST), STREAM_WRITE);
54 		aStream << "Test";
55 		aStream.Close();
56 		ULONG i, nWaitFor = 2000 + Time::GetSystemTicks();
57 		for (i=Time::GetSystemTicks();
58 				 i < nWaitFor;
59 				 i = Time::GetSystemTicks())
60 			;
61 		CheckTimes(aDir);
62 		nWaitFor = 2000 + Time::GetSystemTicks();
63 		for (i=Time::GetSystemTicks();
64 				 i < nWaitFor;
65 				 i = Time::GetSystemTicks())
66 			;
67 		aFile.Kill();
68 	}
69 	else
70 		puts("MakeDir failed!");
71 	return 0;
72 }
73 
CheckTimes(DirEntry aDE)74 void CheckTimes(DirEntry aDE)
75 {
76 	FileStat aDirStat(aDE);
77 	aDirStat.Update(aDE);
78 	Date aDateCreated(aDirStat.DateCreated());
79 	Date aDateModified(aDirStat.DateModified());
80 	Time aTimeCreated(aDirStat.TimeCreated());
81 	Time aTimeModified(aDirStat.TimeModified());
82 	printf(
83 		"DirDateCreated = %i, DirTimeCreated = %i\n",
84 		aDateCreated.GetDate(), aTimeCreated.GetTime());
85 	printf(
86 		"DirDateModified = %i, DirTimeModified = %i\n",
87 		aDateModified.GetDate(), aTimeModified.GetTime());
88 	return;
89 }
90 
91