Skip to content

Instantly share code, notes, and snippets.

@mresetar
Created August 29, 2012 09:14
Show Gist options
  • Save mresetar/3508904 to your computer and use it in GitHub Desktop.
Save mresetar/3508904 to your computer and use it in GitHub Desktop.
Creates longest possible dir name for windows
//http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath
def dirName = 'd:\\tmp\\'
def MAX_PATH = 260
def FILE_NAME = 12
def NULL_SIZE = 1
def i = dirName.length()
while (i < MAX_PATH - FILE_NAME - NULL_SIZE) {
def iLen = (i as String).length()
def currLenValue = i + iLen
def rest = currLenValue % 10
if (rest == 0) { dirName += currLenValue; i += (currLenValue as String).length() }
else {dirName += 'a'; i++}
}
println dirName.length()
println dirName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment