0

Lets say we have a user who wants a file named: "test/lasdhjal.txt", whatever. Now if I put this into a new File(input); object inside, it will think that test/ is a folder, whilst it's a part of the name. What can I do against that?

sero583
  • 15
  • 6

1 Answers1

1

No, the limitation of not allowing a "/" in a file name is imposed at the kernel level, this is not something you can get around.

wyit
  • 363
  • 1
  • 3
  • 10
  • How can some OS handle that then? – sero583 Apr 10 '20 at 21:15
  • My understanding is that none of them do. 1. https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names 2. https://askubuntu.com/questions/719916/how-to-have-a-forward-slash-in-a-file-name – wyit Apr 10 '20 at 21:19
  • You sure? E.g. you can create in windows a folder with a / in it's name. Also for example Minecraft has used to be a file structure, which sometimes included / iirc – sero583 Apr 10 '20 at 21:20
  • 100% sure. Here's a link to a wikepedia list of characters forbidden from windows filenames: https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words – wyit Apr 10 '20 at 21:23