Home » PLAYER'S HQ 1.13 » JA2 Complete Mods & Sequels » Stracciatella Project (Platform Independent JA2) » Make lowercase failed for me, fixed it
Make lowercase failed for me, fixed it[message #266890] Mon, 15 November 2010 00:52 Go to next message
felixhummel is currently offline felixhummel
Messages:1
Registered:November 2010
Hi!

Building JA2 Straciatella trunk failed
a) during "make lowercase" and
b) in game after the helicopter landing
probably because the Data directory came from a gog.com install.

I rewrote the lowercase target which basically makes everything lower case. Here's the diff (for rev. 7072):
Index: lowercase.py
===================================================================
--- lowercase.py	(revision 0)
+++ lowercase.py	(revision 0)
@@ -0,0 +1,22 @@
+# http://stackoverflow.com/questions/3075443/python-recursively-remove-capitalisation-from-directory-structure
+import os
+
+def lowercase_rename( dir ):
+    # renames all subforders of dir, not including dir itself
+    def rename_all( root, items):
+        for name in items:
+            try:
+                os.rename( os.path.join(root, name),
+                                    os.path.join(root, name.lower()))
+            except OSError:
+                pass # can't rename it, so what
+
+    # starts from the bottom so paths further up remain valid after renaming
+    for root, dirs, files in os.walk( dir, topdown=False ):
+        rename_all( root, dirs )
+        rename_all( root, files)
+
+if __name__ == '__main__':
+    import sys
+    dir = sys.argv[1]
+    lowercase_rename(dir)
Index: Makefile
===================================================================
--- Makefile	(revision 7072)
+++ Makefile	(working copy)
@@ -507,11 +507,4 @@
 
 
 lowercase:
-	$(Q)for i in \
-		"$(SGPDATADIR)"/Data/*.[Ss][Ll][Ff] \
-		"$(SGPDATADIR)"/Data/TILECACHE/*.[Jj][Ss][Dd] \
-		"$(SGPDATADIR)"/Data/TILECACHE/*.[Ss][Tt][Ii]; \
-	do \
-		lower="`dirname "$$i"`/`basename "$$i" | LANG=C tr '[A-Z]' '[a-z]'`"; \
-		[ "$$i" = "$$lower" ] || mv "$$i" "$$lower"; \
-	done
+	$(Q)python lowercase.py $(SGPDATADIR)


I hope this is of some help. Smile

Felix

PS: This patch assumes that everybody on *NIX has some version of Python installed.

Report message to a moderator

Civilian
Re: Make lowercase failed for me, fixed it[message #273091] Wed, 09 February 2011 19:53 Go to previous messageGo to next message
qubodup is currently offline qubodup
Messages:1
Registered:February 2011
Hey, I registered to share the bash solution I used:

(Change path in first line)
find /home/test/ -name "*[A-Z]*" -printf "%h:%f
" | awk 'BEGIN{q="\047";FS=":"}
{
 newpath = $1"/"tolower($2)
 cmd = "mv "q $1"/"$2 q" "q newpath q 
 system(cmd)
}
'


taken from how to change file names to uppercase in a directory

Report message to a moderator

Civilian
Re: Make lowercase failed for me, fixed it[message #273108] Wed, 09 February 2011 23:18 Go to previous message
mgl is currently offline mgl

 
Messages:255
Registered:December 2007
Location: France
Welcome qubodup!

Python for felixhummel, awk for you, Perl coming soon.
There is more than one way to make it harder.

Why does the original script in the Makefile fail, it can't find the input files ?
It would fail if "Data" or "TILECACHE" are not written exactly like I quoted them, for example "DATA" or "Tilecache". Is it the case ?

The quickest way to convert the data files to lower case should be to go to the $SGPDATADIR directory, convert the "Data/" folder to lower case, then search and convert anything in "data/" with the command:
for if in $(find data); do of=$(echo $if | tr [] [:lower]); mv $if $of; done

Or even don't care at all for what could exist in $SGPDATADIR besides "Data/" and convert anything found there ($SGPDATADIR) to lower case with the command above adapted to this case.

Report message to a moderator

Master Sergeant
Previous Topic: Stracc for android?
Next Topic: Strac on OpenPandora console - Portable JA2!
Goto Forum:
  


Current Time: Sat Jul 19 11:45:30 GMT+3 2025

Total time taken to generate the page: 0.00489 seconds