Liberty BASIC Community Forum
« For Windows, "data.txt" and "data.txt." are same »

Welcome Guest. Please Login or Register.
Dec 12th, 2017, 08:09am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: For Windows, "data.txt" and "data.txt." are same  (Read 64 times)
tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1708
xx For Windows, "data.txt" and "data.txt." are same
« Thread started on: Nov 23rd, 2017, 02:19am »

While trying to check code for file found/file not found,
I encountered that FILES for
"data.txt..."
returns data for
"data.txt"

First I thought that to be a bug in FILES,
but I saw that C# behaves same way.

After some googling it seems that file name ending with a dot is invalid in Windows - so Windows silently strips final dots.
Here's the code proving that (tested on WinXP SP3. Google says problem manifests in Win7, and I think in lates Windows too.

I really find this amusing.

Code:
'code shows that for Windows,
'   "data.txt"
'and
'   "data.txt..."
'are the same thing
'(tsh73 Nov 2017, tested on XP SP3)

fileName$="data.txt"
'fileName$="data.txt..."    'creates "data.txt", no extra dots

'create data file
open fileName$ for output as #1
    print #1, "data goes here"
close #1

fileName$ = fileName$+"....................."   'opens "data.txt", extra dots are ignored
print "Time stamp for a file ";fileName$
print getFileStamp$(fileName$)


function getFileStamp$(fileName$)
    dim info$(1,1)
    files  DefaultDir$, fileName$, info$()
    if info$(0, 0) = "0" then
        getFileStamp$ = "File not found"
    else
        getFileStamp$ = info$(1, 2)
    end if
end function
 
User IP Logged

damned Dog in the Manger
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls