source: xtideuniversalbios/trunk/Assembly_Library/Src/File/Directory.asm@ 576

Last change on this file since 576 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 4.6 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for accessing directories.
3
[376]4;
[526]5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
[526]12;
[376]13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[526]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
[526]19
[41]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Directory_GetDiskTransferAreaAddressToDSSI
25; Parameters:
26; Nothing
27; Returns:
28; DS:SI: Ptr to DTA
29; Corrupts registers:
30; AX
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33Directory_GetDiskTransferAreaAddressToDSSI:
34 push es
35 push bx
36
37 mov ah, GET_DISK_TRANSFER_AREA_ADDRESS
38 int DOS_INTERRUPT_21h
39 push es
40 pop ds
41 mov si, bx
42
43 pop bx
44 pop es
45 ret
46
47
48;--------------------------------------------------------------------
49; Directory_ChangeToPathFromDSSI
50; Parameters:
51; DS:SI: Ptr to NULL terminated path (max 64 bytes)
52; Returns:
53; AX: Error code
54; CF: Cleared if success
55; Set if error
56; Corrupts registers:
57; Nothing
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60Directory_ChangeToPathFromDSSI:
61 xchg dx, si ; Path now in DS:DX
62 mov ah, SET_CURRENT_DIRECTORY
63 int DOS_INTERRUPT_21h
64 xchg si, dx
65 ret
66
67
68;--------------------------------------------------------------------
69; Directory_WriteCurrentPathToDSSI
70; Parameters:
71; DS:SI: Ptr to destination buffer (64 bytes)
72; Returns:
73; AX: Error code
74; CF: Cleared if success
75; Set if error
76; Corrupts registers:
77; Nothing
78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80Directory_WriteCurrentPathToDSSI:
81 push dx
82
[116]83 mov ah, GET_CURRENT_DIRECTORY ; GET_CURRENT_DIRECTORY = 47h
84 cwd ; Default drive (00h)
[41]85 int DOS_INTERRUPT_21h
86
87 pop dx
88 ret
89
90
91;--------------------------------------------------------------------
92; Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX
93; Parameters:
94; CX: File attributes
95; DS:SI: NULL terminated search string (may include path and wildcards)
96; Returns:
97; AX: Number of matching files found
98; Corrupts registers:
99; Nothing
100;--------------------------------------------------------------------
101ALIGN JUMP_ALIGN
102Directory_GetMatchCountToAXforSearchStringInDSSIwithAttributesInCX:
103 push dx
104 xor dx, dx ; Zero counter
105 call Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
106 jc SHORT .NoMoreFilesFound
107ALIGN JUMP_ALIGN
108.FindNextFile:
109 inc dx ; Increment match count
110 call Directory_UpdateDTAForNextMatchUsingPreviousParameters
111 jnc SHORT .FindNextFile
112ALIGN JUMP_ALIGN
113.NoMoreFilesFound:
114 xchg ax, dx ; Match count to AX
115 pop dx
116 ret
117
118
119;--------------------------------------------------------------------
120; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX
121; Parameters:
122; CX: File attributes
123; DS:SI: NULL terminated search string (may include path and wildcards)
124; Returns:
125; AX: Error code
126; CF: Cleared if success
127; Set if error
128; Disk Transfer Area (DTA) will be updated
129; Corrupts registers:
130; Nothing
131;--------------------------------------------------------------------
132ALIGN JUMP_ALIGN
133Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX:
134 xchg dx, si ; Search string now in DS:DX
135 mov ax, FIND_FIRST_MATCHING_FILE<<8 ; Zero AL (special flag for APPEND)
136 int DOS_INTERRUPT_21h
137 xchg si, dx
138 ret
139
140
141;--------------------------------------------------------------------
142; Directory_UpdateDTAForNextMatchUsingPreviousParameters
143; Parameters:
[116]144; Nothing (Parameters from previous call to
[41]145; Directory_UpdateDTAForFirstMatchForDSSIwithAttributesInCX are used)
146; Returns:
147; AX: Error code
148; CF: Cleared if success
149; Set if error
150; Disk Transfer Area (DTA) will be updated
151; Corrupts registers:
152; Nothing
153;--------------------------------------------------------------------
154ALIGN JUMP_ALIGN
155Directory_UpdateDTAForNextMatchUsingPreviousParameters:
156 mov ah, FIND_NEXT_MATCHING_FILE
157 int DOS_INTERRUPT_21h
158 ret
Note: See TracBrowser for help on using the repository browser.