Kara-Moon Forum
March 28, 2024, 10:18:53 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can go back to the main site here: Kara-Moon site
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Temp files  (Read 2461 times)
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« on: May 04, 2020, 04:26:03 PM »

In another thread:

Quote
elif gbl.playFile:
        import tempfile
        # Currently MMA requires a file name. It would be nice if it
        # could handle file objects...
        # Since otherwise we need to throw away the file handle.
        #(fd,outfile) = tempfile.mkstemp( prefix="MMA", suffix=".mid" )
        outfile = tempfile.mktemp( prefix="MMA", suffix=".mid" )
        MMA.exits.files.append(outfile)
[\quote]

Good idea. Any problem with prefix="MMA." ... if the first rnd character is uppercase the "MMA" part tends to get lost Smiley

Also, it's not that MMA needs the filename (well, it is sort of), but the player probably will need one as well.

Anyway, I've changed it in paths.py. I'll have a quick look for other temp files and do the same.
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #1 on: May 04, 2020, 07:19:58 PM »

The actual filename is not relevant, since it is explicitely passed to the MIDI player and removed afterwards. If the MIDI player can read from a pipe (timidity can) then MMA could pipe the MIDI data directly into the player without the need for a temp file.

About the MMA. prefix: I don't think it has much added value and, as a cautious programmer, I bear in mind that there may be operating systems that dislike more than one dot in a filename.
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #2 on: May 04, 2020, 09:44:10 PM »

Yeah, well, some players can read stdin and others can't. And then there are other OSes ... not a big deal to create a file Wink
Logged

My online life: http://www.mellowood.ca
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #3 on: May 04, 2020, 10:01:18 PM »

I think we are okay with more than one '.' in a filename:
   https://stackoverflow.com/questions/4642028/using-multiple-dots-in-file-names
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #4 on: May 05, 2020, 06:22:05 AM »

From reading the article I'd say no...
a) the poorly written filename extension checker would get confused
Remove all doc and docx files: rm *.doc* -- and gone are my precious  Grin MMA.doc13242.mid files.
b) having MMA. prefix has no added value over whatever. It is a temp file that is going away anyway.

Personally I don't care.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.035 seconds with 19 queries.