question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File resolution without extension

See original GitHub issue

Issue 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:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
mgsx-devcommented, Sep 4, 2020

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.

0reactions
NathanSweetcommented, Sep 4, 2020

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 FileHandle extension method. On the desktop with an absolute path you can just subclass FileHandle rather than a backend specific class.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found