Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Shorten windows paths too long (trim)

by tye (Cardinal)
on Aug 17, 2010 at 17:17 UTC ( #855551=note: print w/ replies, xml ) Need Help??


in reply to Shorten windows paths too long

Can't you just trim the huge path and give 'move' the key not the full path so that you try to run this instead:

cd /d H:/softwaredistribution/hudson/jobs/Conservation_Payment_Release +/workspace/trunk/target/checkout/conservation-ejb-batch/target; move +/Y was6-maven-plugin w6

Update: You don't appear to be that close to the 255 point when the failure happens so the problem is probably that the directory is 'in use' in a way that prevents it from being renamed. The move fails but produces no error message? That is strange. You could get the old SysInternals filemon and see the error reason for the move failing or use Perl's rename and report $! and $^E after that fails.

- tye        


Comment on Re: Shorten windows paths too long (trim)
Download Code
Re^2: Shorten windows paths too long (trim)
by gj2666 (Sexton) on Aug 17, 2010 at 18:23 UTC
    tye, I'll try cd'ing to the dir and passing in just the pathnames.

    Yes, it is really and truly too long. I'm trying to recover some length by shortening some of the directories near the start of the path in order to be able to move them without doing them one at a time by hand.

    H:\so123456789012345ion/hudson/jobs/BFffs/workspace/b1234567-file-pare +nt/target/checkout/persistence-dom/src/main/java/xyz/abcd/fqq/perdom/ +pc/farmoperatingplancontributionpersistentservice/.svn/text-base/Stor +eManagementContributionDeclarationPC.java.svn-base,
    258 characters

    But you're right, the error occurs on a node in the path way before length becomes a problem. It works manually and that's what has me stumped.

    I am getting "Bad File Descriptor" in the files that I don't want to change anyway, but on the ones that I want to change I get nothing. I'm debugging in komodo interactively so if there were anything there I should see it on $! as I step through the code.

      Ok, now I see that indeed you have a 258 char path. Once you exceed one of these "magic power of 2" boundaries, the results can be unpredictable, often due to due to lower level things related to memory allocation. In this case, I suspect that you have a classic buffer overflow problem.

      Sometimes you "get away with it" and sometimes not! The command line version may use different memory allocation than some other version - this is in any event, "fragile" code that depends upon being lucky!

      It appears to me that (a) you have a relatively small number of paths (70), that need to be shorted by a very modest amount - at least 3 chars, but I would try to go more than that for later expansion.

      You could build a translation table. Say shortening "persistence-dom" to just "persistD". That alone would solve your immediate problem and get total path characters to less than 255. Throw some other translations in there and you can get to less than 200 chars.

      There is a post in this node about "subst" which is one way to implement the "mount point" idea that I suggested earlier, and that is one way to go.

      There is also a post that suggests an obvious solution: Don't generate path's with more than 255 chars! Explain to your users why this is important and a big pain in the ass to deal with and they will understand it.

      The best solution is that everybody generates stuff that is easy to deal with, understands what the rules are, and why that makes sense. I would counsel you to get out of the file path/name translation business. If you don't, this will be a never ending assignment for you. In short, talk to your users, explain what grief this causes and some simple steps that they can do which eliminates this grief and is better for everybody.

        There is also a post that suggests an obvious solution: Don't generate path's with more than 255 chars! Explain to your users why this is important and a big pain in the ass to deal with and they will understand it.
        Oh gee, sure, I never thought of that suggestion. *eyerolling*. I have on numerous occasions suggested to the java dingleberry developers I work with that perhaps having a class called "findthefarmerwhohasthemostacerageandaskhimifhedliketobuyatractor.java" might be a candidate for abbreviation.

        Apparently making me happy and their own lives less complicated is not their priority.

        I created a hash in the code I added to my original post to do the very thing you suggest, a substitution table.
        Unfortunately I can't seem to get the substitute command to actually do the job.

        I will try your stat suggestion and hopefully that will give me help.

        Thank you for responding with a thoughtful and very readable answer btw.

Re^2: Shorten windows paths too long (trim)
by gj2666 (Sexton) on Aug 18, 2010 at 15:27 UTC
    Apparently not. I will continue my quest...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://855551]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-09-20 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls