Skip to content

Commit

Permalink
Merge pull request #336 from VineetReynolds/FORGE-93
Browse files Browse the repository at this point in the history
FORGE-93 Return correct qualified path on Windows
  • Loading branch information
gastaldi committed Jul 23, 2013
2 parents 5121b8e + 93456f3 commit d027ff5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public String getName()
{
return file.getName();
}

@Override
public String getFullyQualifiedName()
{
return file.getAbsolutePath();
}

/**
* Get the actual underlying file resource that this resource instance represents, whether existing or non-existing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,22 @@ private String capture()
{
int start = cursor;

// capture can start with a '/'
if (path.charAt(cursor) == '/')
// capture can start with a '/' or '\\' (the latter on Windows only)
if (path.charAt(cursor) == '/' || (OSUtils.isWindows() && path.charAt(cursor) == '\\'))
{
cursor++;
}

while ((cursor < length) && (path.charAt(cursor) != '/'))
while ((cursor < length))
{
if (OSUtils.isWindows() && path.charAt(cursor) == '\\')
{
break;
}
if (path.charAt(cursor) == '/')
{
break;
}
cursor++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void run()
{
int read = consoleStream.read();
blockingQueue.put(read);
Thread.sleep(10);
Thread.yield();
}
catch (IOException e)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ public void run()
{
int read = WindowsSupport.readByte();
blockingQueue.put(read);
Thread.sleep(10);
Thread.yield();
}
catch (InterruptedException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jboss.forge.shell.command.parser.CommandParserContext;
import org.jboss.forge.shell.util.BeanManagerUtils;
import org.jboss.forge.shell.util.JavaPathspecParser;
import org.jboss.forge.shell.util.OSUtils;
import org.jboss.forge.shell.util.PathspecParser;

public class OptionValueResolverCompleter implements CommandCompleter
Expand Down Expand Up @@ -194,7 +195,9 @@ else if (valueMap.get(option) == null)
results.add(name);
}

int lastNest = val.lastIndexOf(File.separatorChar);
int lastForwardSlash = val.lastIndexOf('/');
int lastBackslash = OSUtils.isWindows() ? val.lastIndexOf('\\') : -1;
int lastNest = Math.max(lastForwardSlash, lastBackslash);

// Record the current index point in the buffer. If we're at
// the separator char
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.jboss.forge.shell.plugins.builtin;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

Expand Down Expand Up @@ -96,7 +97,7 @@ public static String promptExpressionParser(Shell shell, String input)
case 'W':
builder.append(new String(expr, start, i - start - 1));
String v = (String) shell.getEnvironment().getProperty("CWD");
builder.append(v.substring(v.lastIndexOf('/') + 1));
builder.append(v.substring(v.lastIndexOf(File.separator) + 1));
start = i + 1;
break;

Expand Down

0 comments on commit d027ff5

Please sign in to comment.