I created file with CX=0.
mov CX,0
mov AH,3Ch
int 21h
After I look it's attributes. It was cx=20h. It means arch bit is setup.
mov AH,43h
xor AL,AL
int 21h
Why is it?
source:
create_c\
SEGMENT
$start:
mov AX,SEG(file_name)
mov DS,AX
lea DX,file_name
mov CX,0
mov AH,3Ch
int 21h
jc $error
mov BX,AX
mov AH,3Eh
int 21h
mov AH,43h
xor AL,AL
int 21h
jmp $exit
$error:
mov DL,'E'
mov AH,2h
int 21h
$exit:
mov AH,4Ch
int 21h
create_c\
ENDS
create_d\
SEGMENT
file_name\
BYTE 'A:\test.txt',0
create_d\
ENDS
create_s\
SEGMENT STACK
BYTE 256\
DUP (?)
create_s\
ENDS
END $start
From the Microsoft MS-DOS Programmer's Reference, Version 5, Microsoft Press, 1991, Chapter 3: File System, File Management:
ATTR_ARCHIVE (20h)
Specifies a file that is new or has been modified. The system automatically sets this attribute when the file is created or written to. The attribute does not affect access to the file but gives programs a quick way to check for potential changes to the file contents.
Quote from: MichaelW on April 13, 2007, 09:34:39 AM
From the Microsoft MS-DOS Programmer's Reference, Version 5, Microsoft Press, 1991, Chapter 3: File System, File Management:
ATTR_ARCHIVE (20h)
Specifies a file that is new or has been modified. The system automatically sets this attribute when the file is created or written to. The attribute does not affect access to the file but gives programs a quick way to check for potential changes to the file contents.
But i want create file with clear arch bit and i set CX=0.
So after you close the file, set its attributes
mov ax,4301h
sub cx,cx
mov dx,OFFSET file_name
int 21h
Quote from: sinsi on April 13, 2007, 12:08:40 PM
So after you close the file, set its attributes
mov ax,4301h
sub cx,cx
mov dx,OFFSET file_name
int 21h
I know it.
Why does this function ignore my arch attr value?
I set value of 0.
The function works correctly for me, testing under Windows 2000.
Quote from: MichaelW on April 14, 2007, 06:49:14 AM
The function works correctly for me, testing under Windows 2000.
By correctly do you mean the archive bit is set (as per DOS ref) or archive bit is clear (CX=0)?
Under XPHSP2, as soon as the file is created it has the archive attribute set.
Either way, I tested with code that toggles the attribute:
mov ax,4300h
mov dx,OFFSET fn
int 21h
xor cx, 20h
mov ax,4301h
mov dx,OFFSET fn
int 21h
Quote from: MichaelW on April 14, 2007, 07:25:13 AM
Either way, I tested with code that toggles the attribute:
mov ax,4300h
mov dx,OFFSET fn
int 21h
xor cx, 20h
mov ax,4301h
mov dx,OFFSET fn
int 21h
I try to do it (debug my code) under xpsp2 too and will do it under win95osr2.
I think that it is not logical arcitecture of dos subsys.
I agree that it seems illogical to set the archive attribute when the file is created.
I tested the Extended Open/Create function (6C00h), and the OS/2 "DosOpen2" function (6C01h), which surprisingly is supported under Windows 2000, with every variation of open mode and action that I thought might have an effect on the archive attribute. In every case the archive attribute was set after the file was created. The extended Open/Create function was added starting with MS-DOS 4.0, which IIRC was actually developed by IBM. My search for an undocumented file creation function turned up nothing likely to work.
The purpose of the archive flag is to indiate which files have not yet been backed-up (archived), or have been modified since the last back-up. When the archive program runs, it clears the archive-flag on each file it archives, so that it's not included the next time (unless it's subsequently modified and thus is labelled for archive again.)
So, when you create a new file, it is logical that the archive bit should be set - as the file was not included in the previous back-up.
Of course, if you want to create a file without the archive flag, then you should at least be allowed to do so ::)
But I guess that's why it adds the archive attribute by default.
Well, perhaps that was the underlying logic, but after the file is created it has a length of zero. Is it normal for archiving programs to include zero-length files?
Well it does seem fairly pointless to include a zero-length file, but sometimes they are used to indicate particular things, and if it was so useless why was it created? The safest thing to do is include it just in case. Te same goes for empty folders - just because they don't currently contain files, doesn't mean they never will or shouldn't exist.