Always use portable.rename unless you know that the code in question will never run on Windows.
In the case of the driver action, that is OpenSolaris only. (eventually, the fix for 870 will enforce that) In the file action, the os.rename that is there is actually in Windows-specific code, but that code is written with the limitations of Windows in mind. In the cfgfiles.py module, the whole module is POSIX only (there is a comment at the top of the file to that effect). Again, this will eventually be enforced by a fix to 870. Those are the only cases of os.rename left. BTW, last year, James wrote a set of best practices for writing portable code on the pkg(5) project. See: http://cr.opensolaris.org/~jhf/mp-1.html I have updating and posting this on my todo list, but I've never found out how or been given permission to edit the opensolaris.org site with the document. Maybe it would be a good time to do that. Tom [EMAIL PROTECTED] wrote: > Thanks for the explanation. > > When is it desireable to use portable.rename instead of os.rename? > There are still some places in the code that use os.rename (file and > driver actions, I think). Should new code be using portable.rename, or > are there situations where os.rename is still okay? > > -j > > On Tue, Oct 28, 2008 at 02:45:23PM -0500, Tom Mueller (pkg-discuss) wrote: > >> On Unix, portable.rename is just os.rename. >> On Windows, portable.rename moves an existing file aside if there is one >> before doing the rename, giving the same behavior as you get with Unix. >> >> So to answer your question, portable.rename has the same limitation WRT >> file system boundaries as os.rename. >> >> Thanks for looking at this. >> Tom >> >> [EMAIL PROTECTED] wrote: >> >>> These changes look okay to me. >>> >>> Does portable.rename prohibit renames across filesystem boundaries? >>> I ran into this with os.rename, which is why I ask. >>> >>> -j >>> >>> On Tue, Oct 28, 2008 at 01:55:55PM -0500, Tom Mueller (pkg-discuss) wrote: >>> >>> >>>> Issue: 4296 Catalog.recv uses os.rename rather than portable.rename >>>> http://defect.opensolaris.org/bz/show_bug.cgi?id=4296 >>>> >>>> webrev: http://cr.opensolaris.org/~tmueller/cr-4296/ >>>> >>>> The fix is per the suggestion in the bug (replace os.rename with >>>> portable.rename) >>>> >>>> Thanks. >>>> Tom >>>> >>>> _______________________________________________ >>>> pkg-discuss mailing list >>>> [email protected] >>>> http://mail.opensolaris.org/mailman/listinfo/pkg-discuss >>>> >>>> >> _______________________________________________ >> pkg-discuss mailing list >> [email protected] >> http://mail.opensolaris.org/mailman/listinfo/pkg-discuss >> _______________________________________________ pkg-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
