[PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Windows specific forum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

[PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by IdeasVacuum »

There seems to be a bug:

Code: Select all

sFile.s = "C:\PROJECTS\M100\HARDWARE INFO\IGSTK44\Testing\.NoDartCoverage"
Debug GetFilePart(sFile, #PB_FileSystem_NoExtension)
In this case, the file has no file name, only an extension, but the extension is returned as the file name.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by eddy »

on linux, there's a kind of file:

Code: Select all

.htaccess
Is it a file name or a special extension ?
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by ts-soft »

eddy wrote:on linux, there's a kind of file:

Code: Select all

.htaccess
Is it a file name or a special extension ?
This is a file name. The dot in front stays for hidden!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by IdeasVacuum »

Well, my example, .NoDartCoverage, is in fact a file name that has no extension and is preceded with a ".".

So, therefore this is not a PB bug. It is a pita though, because it chokes 7zip :?

I'll need to test each file name for this.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by jassing »

IdeasVacuum wrote:Well, my example, .NoDartCoverage, is in fact a file name that has no extension and is preceded with a ".".
I read it as it's a filename that contains a blank name ("") and an extension.

In windows, dos, etc -- [filename] . [extension]

it gets more complicated if you have multiple periods, but we've always looked at it as the final '.' indicates the start of the extension.

This.Is.A.File.Name.With.Multiple.Periods

where "Periods"would be the extension. Treating it this way has proved trouble free....
TassyJim
Enthusiast
Enthusiast
Posts: 191
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by TassyJim »

If you look at the file in Windows Explorer, it is described as a 'NoDartCoverage' file.
Windows treats it as an extension.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by IdeasVacuum »

It's a build file for a cpp API, basically a text file containing one or two lines of text. Presumably for the process it belongs to, the naming is convenient. Certainly the info inside is nothing special. Would be interesting to see what Fred makes of it.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by IdeasVacuum »

Well, the plot thickens - I have several files of this type (they are not all ".NoDartCoverage").

I have discovered that RenameFile() fails to rename them

Code: Select all

sNewName$ = "new" + sOldName$
RenameFile(sOldName$, sNewName$)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
acreis
Enthusiast
Enthusiast
Posts: 241
Joined: Fri Jun 01, 2012 12:20 am

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by acreis »

I have made some experiences with windows explorer (WinXP), but I can't create a file with name in this format: ".extension" or ".filename".

Obviously "filename.extension" is OK.

It is possible that the system was not designed to accept a filename that contains only an extension, with no filename, or a filename with only one dot at its beggining is, by design, considered incorrect.
User avatar
JHPJHP
Addict
Addict
Posts: 2273
Joined: Sat Oct 09, 2010 3:47 am

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by JHPJHP »

Hi acreis,

One way to "have" a filename with only an extension is to zip/rar a group of files, rename them using WinRAR or whatever software you use, then extract them to your desktop... or just use RenameFile (PureBasic) or MoveFile_ (Windows API) - both worked the same for the tests I performed.

I was able to rename (using scripts) to the standard naming convention, then back to "extension only" with no trouble using both functions.

---------------------------------------

Hi IdeasVacuum (stuff you probably know) :) ,

While testing - try to rename the files manually? A lot of the time, not being able to rename/delete a file is caused by an orphand process still having some type of lock.

A few "other" things to try:
Escape character: "C:\\Documents and Settings\\Administrator\\Desktop\\.test"
Forward slash: "C:/Documents and Settings/Administrator/Desktop/.test"
8.3 Short name: ""C:\Docume~1\Administrator\Desktop\test.txt"
Relative path: "./Desktop/.test"

Did not work for Rename / MoveFile_, but may work within 7-Zip (if any issues still exist):
#DQUOTE$ + "C:\Documents and Settings\Administrator\Desktop\test.txt" + #DQUOTE$

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by IdeasVacuum »

It's 7z that does not like the files as-is. A common factor with these files is that they arrive with 'large' apps like CAD/CAM. So, seems likely that the developers of these apps are using the same or similar methods of packaging the apps, which usually have 100s of supporting files, including dll, exe, you name it.

None of the files are locked, I can re-name them manually and the text content remains intact. So, I'd like to know what Fred thinks.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Demivec
Addict
Addict
Posts: 4282
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: [PB5.20 Beta12] GetFilePart() #PB_FileSystem_NoExtension

Post by Demivec »

IdeasVacuum wrote:Well, my example, .NoDartCoverage, is in fact a file name that has no extension and is preceded with a ".".

So, therefore this is not a PB bug. It is a pita though, because it chokes 7zip :?
I think it may still be a PB bug but the bug is with GetExtensionPart() and not GetFilePart().

What should this simple test display?

Code: Select all

Procedure testit(t.s)
  Debug "complete file name --" + t + "--"
  Debug "file part only --" + GetFilePart(t, #PB_FileSystem_NoExtension) + "--"
  Debug "extension part only --" + GetExtensionPart(t.s) + "--"
EndProcedure


testit(".NoDartCoverage")
In this example the file part shows ".NoDartCoverage" and the extension part shows "NoDartCoverage". I'll post a bug report regarding this problem with GetExtensionPart(), at least for windows.
Post Reply