File resolution without extension
See original GitHub issueIssue details
When I generate cached MP3 files from other game resource files, I don’t want the extension on purpose, but I need extension when I play it
Reproduction steps/code
package com.badlogic.gdx.files;
public class FileHandle{
...
protected String extension;
/**
* Add an attribute and a method to find a suitable parser for the no extension file.
* Call the last line of all constructor methods ex: setExtension(null);
* @param extension suffix
*/
public void setExtension(String extension) {
if (extension == null) {
String name = this.file.getName();
int dotIndex = name.lastIndexOf(46);
this.extension = dotIndex == -1 ? "" : name.substring(dotIndex + 1);
} else {
this.extension = extension;
}
}
...
/** Returns the file extension */
public String extension () {
return extension;
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Picture file without extension [duplicate] - Super User
Rename the file and add the extension .SVG (Scalable Vector Graphics) and you will be able to open it in Internet Explorer, Chrome,...
Read more >Use Python to find the resolution of image with any image file ...
Use Python to find the resolution of image with any image file extension without using any non-default library · 1. Image. · @GammaGames...
Read more >Local Modal Resolution without file extensions #4722 - GitHub
I know using bundlers (micro-bundle, babel, etc) it's possible to import local ESModules without needing to include file extensions.
Read more >Identifying jpegs without extension and recursively moving ...
The idea is to recursively dig through folder structure of iPhone backup files (renamed without extensions) to identify jpegs and copy them ...
Read more >Photo Image file formats, TIF, JPG, PNG, GIF. Which to use?
JPG is the file extension for JPEG files (Joint Photographic Experts Group, ... for video screen purposes, GIF does Not retain printing resolution...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Extension is part of the path, changing extension would mean changing the path which mean it’s not the same file handle. Faking things like this would totally change what a FileHandle is and make it inconsistent. That’s not a valid use case IMO.
I agree it would be odd to set an extension on a FileHandle, as the extension comes from the path.
Seems OP’s issue is that Audio
newSound
/newMusic
uses the extension to decide how to parse the file. We’d need to add a new Audio method to allow choosing how the file is parsed without using the extension. A workaround may be to subclass FileHandle and return a hardcoded value for the FileHandleextension
method. On the desktop with an absolute path you can just subclass FileHandle rather than a backend specific class.