chipmunk icon indicating copy to clipboard operation
chipmunk copied to clipboard

Detect file type

Open sudeeptarlekar opened this issue 2 years ago • 5 comments

Rustcore should have functionality to detect the file type. If file type is binary or text, and if text what is the encoding of file.

Resolves: #1841

sudeeptarlekar avatar Oct 18 '23 09:10 sudeeptarlekar

Location

We have a nice suitable place for it application/apps/indexer/addon, but now it's just one module. I would suggest (if @marcmo agree):

  • rename application/apps/indexer/addon into application/apps/indexer/addons
  • current lib in application/apps/indexer/addon rename into dlt-tools and add as submodule
  • same for your tool, create files-tools and add there

It will be something like:

-- addons
---- dlt-tools
------ src
------ Cargo.tolm
---- files-tools
------ src
------ Cargo.tolm

Create it as lib and add tests of course.

Artifacts for tests

Also, take into account, we have this place developing/resources. Here you can store resources for testing. You can left there some example files, which you would use for testing.

General idea

I think reading some parts of target-file and searching "specific binary or not binary" symbols is a good idea and the right direction. Just a question, would it be simple just try some chunks of file with std::str::from_utf8. Because if it isn't UTF8: you will get error or result string len will be != to the len of given byte's slice. That's just an idea, I don't know what is a better.

Good habit

As soon as it's draft, no problems of course to skip cargo clippy, but I would recommend doing it always before pushing with rake clippy:all... As usual, it gives you nice and useful recommendations about code styling and allows you to better understand rust philosophy

DmitryAstafyev avatar Oct 20 '23 07:10 DmitryAstafyev

DO NOT MERGE in the name of PR scares me )) sounds like a bomb in our solution)) If your PR in the draft state it will not be merged - no worries )

DmitryAstafyev avatar Oct 20 '23 07:10 DmitryAstafyev

linked to: #1921, #1841

DmitryAstafyev avatar Oct 20 '23 07:10 DmitryAstafyev

indexer/addon is a good place...no need to rename to addons

marcmo avatar Oct 20 '23 07:10 marcmo

Is this good to 🚢 ? Asking as I was bit skeptical about changes...

sudeeptarlekar avatar Dec 02 '23 03:12 sudeeptarlekar