Re: Long filenames
On Wed, 6 Jan 1999, Andrew Sharp wrote:
> I'm writing a program under Dos32 which generates long filenames. I've
> heard that Euphoria can deal with long filenames but mine won't work.
> I think it's because the first 8 digits of some of them are the same,
> (and need to stay the same) eg "m3572856" "m35728564" "m357285641" etc.
> As far as I know I'm going to have to write a filename "nanny" which will
> allow me to attach one filename to it's parent (specific to this program).
> I think I've got that thought out but it's going to be complicated.
> At the moment, when the file name grows past the 8 digits, E just refuses
> to open the file. No error messages, no crash, which makes me wonder if
> there might be an easier way lurking near.
> Any ideas?
Yup. For the file-splitter I wrote, I wanted to deal with Long Filenames.
Here's part of the split.e library I wrote for it:
-- win95fh.e --
---------------------------------------------------------------------------
-- [Windows 95] File Handling --
---------------------------------------------------------------------------
global function exist(sequence filename)
integer status
--system("cd " & current_dir(), 2)
-- open() works on Win95 filenames!
status = open(filename, "rb")
if status != -1 then
close(status)
return 1
end if
return 0
end function
global function is_long_filename(sequence filename)
-- Not perfect but does a fairly good job...
integer dotpos
dotpos = find('.',filename)
if dotpos then
filename[dotpos] = -'.'
end if
if find('.',filename) or find(' ', filename) or
(dotpos = 0 and length(filename) > 8) or
(dotpos > 0 and length(filename)-dotpos > 3)then
return 1
else
return 0
end if
end function
global function open95(sequence filename, sequence mode)
integer handle
if not length(mode) or not length(filename) then
return -1
end if
if mode[1] != 'r' then
if not exist(filename) then
if is_long_filename(filename) then
system("rem > \"" & filename & "\"", 2)
else
system("rem > " & filename, 2)
end if
end if
end if
handle = open(filename, mode)
return handle
end function
-- end win95fh.e --
Happy coding,
Carl
--
Carl R White -- Final Year Computer Science at the University of Bradford
E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :)
URL......: http://www.bigfoot.com/~cyrek/
Ykk rnyllaqur rgiokc cea nyemdok ymc giququezka caysgr -- B.Q.Vgesa
|
Not Categorized, Please Help
|
|