- Use Unicode strings instead of WCHAR strings.
[reactos.git] / reactos / drivers / fs / cdfs / misc.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2002, 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: misc.c,v 1.8 2004/09/14 21:46:39 ekohl Exp $
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/cdfs/misc.c
24 * PURPOSE: CDROM (ISO 9660) filesystem driver
25 * PROGRAMMER: Eric Kohl
26 * UPDATE HISTORY:
27 */
28
29 /* INCLUDES *****************************************************************/
30
31 #include <ddk/ntddk.h>
32
33 #define NDEBUG
34 #include <debug.h>
35
36 #include "cdfs.h"
37
38
39 /* FUNCTIONS ****************************************************************/
40
41 VOID
42 CdfsSwapString(PWCHAR Out,
43 PUCHAR In,
44 ULONG Count)
45 {
46 PUCHAR t = (PUCHAR)Out;
47 ULONG i;
48
49 for (i = 0; i < Count; i += 2)
50 {
51 t[i] = In[i+1];
52 t[i+1] = In[i];
53 if (t[i+1] == 0 && t[i] == ';')
54 break;
55 }
56 t[i] = 0;
57 t[i+1] = 0;
58 }
59
60
61 VOID
62 CdfsDateTimeToFileTime(PFCB Fcb,
63 TIME *FileTime)
64 {
65 TIME_FIELDS TimeFields;
66
67 TimeFields.Milliseconds = 0;
68 TimeFields.Second = Fcb->Entry.Second;
69 TimeFields.Minute = Fcb->Entry.Minute;
70 TimeFields.Hour = Fcb->Entry.Hour;
71
72 TimeFields.Day = Fcb->Entry.Day;
73 TimeFields.Month = Fcb->Entry.Month;
74 TimeFields.Year = Fcb->Entry.Year + 1900;
75
76 RtlTimeFieldsToTime(&TimeFields,
77 (PLARGE_INTEGER)FileTime);
78 }
79
80
81 VOID
82 CdfsFileFlagsToAttributes(PFCB Fcb,
83 PULONG FileAttributes)
84 {
85 /* FIXME: Fix attributes */
86
87 *FileAttributes = // FILE_ATTRIBUTE_READONLY |
88 ((Fcb->Entry.FileFlags & FILE_FLAG_HIDDEN) ? FILE_ATTRIBUTE_HIDDEN : 0) |
89 ((Fcb->Entry.FileFlags & FILE_FLAG_DIRECTORY) ? FILE_ATTRIBUTE_DIRECTORY : 0) |
90 ((Fcb->Entry.FileFlags & FILE_FLAG_SYSTEM) ? FILE_ATTRIBUTE_SYSTEM : 0) |
91 ((Fcb->Entry.FileFlags & FILE_FLAG_READONLY) ? FILE_ATTRIBUTE_READONLY : 0);
92 }
93
94 /* EOF */