2

a have made a proc which create a file for me (in assembly 16 bit in dos box) and it work just fine with short file name(see below). however, when the name is above 8 chars all the others are deleted. for example for the path: 'logs\log_YYYY_MM_DD.log', 0 it will create a file with the name log_YYYY.log how can i make a file with name longer than 8 chars. Thank you.

;---------------------------CreateFile-----------------------------
; Description:  create a file.
; param 1:      [in] address of File name path.
; Param 2:      [out] address of File handle.
; Return:       File handle.
;------------------------------------------------------------------
proc CreateFile
    pusha
    mov bp, sp

    @CreateFile@FileName        equ [word ptr bp + 20]
    @CreateFile@FileHandle      equ [word ptr bp + 18]

    mov ah, 3ch                     ; create file
    mov cx, 0                       ; file attribute
    mov dx, @CreateFile@FileName    ; file name 
    int 21h

    jc @CreateFile@Error
    mov bx, @CreateFile@FileHandle  
    mov [word ptr bx], ax

    jmp @CreateFile@End
@CreateFile@Error:
    call PrintFileError     ;prints an error msg

@CreateFile@End:    
    popa
    ret 2
endp CreateFile
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • See http://www.fysnet.net/longfile.htm It seems like what you want to do is possible only if you run your program in Windows 9x, not in a pure DOS environment. – Michael Apr 22 '20 at 12:19
  • on real DOS (i.e. DOS 6.22 and earlier) you can't as DOS doesn't know about long file names. On DOS 7 (shipped with Windows 95), you can use the long file name functions. See functions in the LONG FILENAME category in [Ralf Brown's interrupt list](http://www.ctyme.com/intr/cat-010.htm). – fuz Apr 22 '20 at 12:26

1 Answers1

3

how can i make a file with name longer than 8 chars

You can't. DOS supports only 8.3 filenames.


More specifically, the version of DOS implemented in DOSBox does not support long filenames.

From Wikipedia:

Forks such as DOSBox SVN Daum and DOSBox SVN-lfn provide additional features, which include support for save states and long filenames (LFN)

So there are variants of DOSBox that do support long filenames, but the core version does.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
  • DOS 7 (i.e. Windows 95) does support long file names as does FreeDOS if I recall correctly. It's however certainly not a mainstream DOS feature. – fuz Apr 22 '20 at 12:21
  • 1
    @fuz: FreeDOS has some support for LFNs, such as FreeCOM's DIR command showing them. However, the kernel has no LFN support built-in. Much like MS-DOS 7/8 in DOS mode (without the MSWindows parts having taken over), you need the DOSLFN program resident to add LFN support (for local FAT FS). I don't know about DOSBox but dosemu does support LFNs for its redirected (host access) FSs. – ecm Apr 22 '20 at 21:48
  • 1
    DOSBox does not support long filenames. – Jonathon Reinhart Apr 24 '20 at 06:25