Subversion Repositories SvarDOS

Rev

Rev 990 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 990 Rev 1736
Line 1... Line 1...
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021-2022 Mateusz Viste
4
 * Copyright (C) 2021-2024 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Line 125... Line 125...
125
    mov ah, 0x40   /* DOS 2+ -- write to file (CX bytes from DS:DX) */
125
    mov ah, 0x40   /* DOS 2+ -- write to file (CX bytes from DS:DX) */
126
    mov bx, [dsth] /* file handle */
126
    mov bx, [dsth] /* file handle */
127
    /* mov dx, [buff] */ /* DX points to buffer already */
127
    /* mov dx, [buff] */ /* DX points to buffer already */
128
    int 0x21       /* CF clear and AX=CX on success */
128
    int 0x21       /* CF clear and AX=CX on success */
129
    jc FAIL
129
    jc FAIL
130
    cmp ax, cx     /* sould be equal, otherwise failed */
130
    cmp ax, cx     /* should be equal, otherwise failed */
131
    mov ax, 0x08   /* preset to DOS error "Insufficient memory" */
131
    mov ax, 0x08   /* preset to DOS error "Insufficient memory" */
132
    jne FAIL
132
    jne FAIL
133
    jmp COPY
133
    jmp COPY
134
 
134
 
135
    ENDOFFILE:
135
    ENDOFFILE:
Line 138... Line 138...
138
    jmp CLOSESRC
138
    jmp CLOSESRC
139
 
139
 
140
    FAIL:
140
    FAIL:
141
    mov [errcode], ax
141
    mov [errcode], ax
142
 
142
 
-
 
143
    /* close src and dst, but first take care to clone the timestamp to dst */
143
    CLOSESRC:
144
    CLOSESRC:
144
    /* close src and dst */
-
 
145
    mov bx, [srch]
145
    mov bx, [srch]
146
    cmp bx, 0xffff
146
    cmp bx, 0xffff /* skip if not a file */
147
    je CLOSEDST
147
    je CLOSEDST
-
 
148
    mov ax, 0x5700 /* DOS 2+ - GET FILE'S LAST-WRITTEN DATE AND TIME */
-
 
149
    int 0x21  /* time and date are in CX and DX now */
-
 
150
    /* proceed with closing the file */
-
 
151
    /* mov bx, [srch] */
148
    mov ah, 0x3e   /* DOS 2+ -- close a file handle */
152
    mov ah, 0x3e   /* DOS 2+ -- close a file handle */
149
    int 0x21
153
    int 0x21
150
 
154
 
151
    CLOSEDST:
155
    CLOSEDST:
-
 
156
    mov ax, bx     /* save src handle, because I'll need it in a moment */
152
    mov bx, [dsth]
157
    mov bx, [dsth]
153
    cmp bx, 0xffff
158
    cmp bx, 0xffff
154
    je DONE
159
    je DONE
-
 
160
    /* set timestamp, unless src was in error or operation was appending */
-
 
161
    cmp ax, 0xffff /* skip date/time setting if source was not open */
-
 
162
    je SKIPDATESAVE
-
 
163
    /* skip timesetting also if appending */
-
 
164
    xor al, al
-
 
165
    cmp [appendflag], al
-
 
166
    jne SKIPDATESAVE
-
 
167
    /* do the job */
-
 
168
    mov ax, 0x5701 /* DOS 2+ - SET FILE'S LAST-WRITTEN DATE AND TIME */
-
 
169
    /* BX=file handle  CX=TIME  DX=DATE */
-
 
170
    int 0x21
-
 
171
    SKIPDATESAVE:
155
    mov ah, 0x3e   /* DOS 2+ -- close a file handle */
172
    mov ah, 0x3e   /* DOS 2+ -- close a file handle */
156
    int 0x21
173
    int 0x21
157
 
174
 
158
    DONE:
175
    DONE:
159
  }
176
  }