Unique file


















The callback function allows the caller to use their own method to create unique file names. If defined, the callback should take three arguments:.

You must log in before being able to contribute a note or feedback. If yes, ensure the new file name will be unique and will produce unique sub-sizes. It will be added later if needed. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Python: How to create a unique file name? Ask Question. Asked 11 years, 7 months ago. Active 1 year, 6 months ago.

Viewed k times. I think what I need to do is: Generate a unique file name Create a temporary file with that name in the working directory Save the values passed from textarea into the temporary file Execute the commandline program from inside my python module and pass it the name of the temporary file I am not sure how to generate a unique file name. Thanks for your concern. MysticCodes MysticCodes 2, 5 5 gold badges 21 21 silver badges 32 32 bronze badges. I edited your question to try and make it more clear.

Let me know if I interpreted something incorrectly! Add a comment. Active Oldest Votes. I didn't think your question was very clear, but if all you need is a unique file name Kostanos 8, 4 4 gold badges 43 43 silver badges 59 59 bronze badges. EnigmaCurry EnigmaCurry 5, 2 2 gold badges 21 21 silver badges 15 15 bronze badges. Sorry i am working on windows platform so dont know how to handle subprocess — MysticCodes.

I dont think its better to have file name with long string and UUID, in it. I think uuid. ToloPalmer: It's more likely that your computer's CPU has a processing error that causes it to load the wrong file than it is a generated UUID collides with any existing value. UUID produces a unique name in a model of computing that understands not all computation is pure mathematics. Pardon my ignorance old comment Indeed is not unique but very unlikely to collide, so good choice ; — Tolo Palmer.

Show 1 more comment. Richard Barrell Richard Barrell 4, 2 2 gold badges 20 20 silver badges 16 16 bronze badges. Can i make that temporary file name unique too? Terence Honles: I'd suggested tempfile. NamedTemporaryFile originally, but you can't really use that to make temporary files that other processes can access on Windows. I guess that's good to know — Terence Honles. This is one function to generate random file name in c program.

This function will generate file name with few random character and the number of character not fixed. Basically it returns cryptographically strong. This is another way to generate unique file name. Those who are not trust guid enough they implement combination of both guid and timestamp.

We know timestamp is nothing but combination of current time with hour ,minute ,second even millisecond. And if we concatenate this combination with GUID random string then I hope always it will throw a unique string even in strong multi threading environment. In below I have given sample code to implement this. The output screen is in below.

Those are the three different approach to generate file name in C. If you find another please write in comment. Comments or Responses.



0コメント

  • 1000 / 1000