1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-14 03:35:37 +02:00

[189498] null checks for source attributes

This commit is contained in:
David McKnight 2007-06-01 19:05:40 +00:00
parent ce42724910
commit c0212e6a24

View file

@ -170,7 +170,11 @@ public class DStoreHostFile implements IHostFile
else else
{ {
String str = getAttribute(_element.getSource(), ATTRIBUTE_IS_HIDDEN); String str = getAttribute(_element.getSource(), ATTRIBUTE_IS_HIDDEN);
return(str.equals("true")); //$NON-NLS-1$ if (str != null && str.length() > 0)
{
return(str.equals("true")); //$NON-NLS-1$
}
return false;
} }
} }
} }
@ -193,8 +197,8 @@ public class DStoreHostFile implements IHostFile
String name = _element.getName(); String name = _element.getName();
if (parentPath == null || if (parentPath == null ||
parentPath.length() == 0 || parentPath.length() == 0 ||
(name.length() == 0 && (parentPath.equals("/") || parentPath.endsWith(":\\")) || (name.length() == 0 && (parentPath.equals("/") || parentPath.endsWith(":\\")) || //$NON-NLS-1$ //$NON-NLS-2$
(name.equals(parentPath) && parentPath.endsWith(":\\"))) //$NON-NLS-1$ //$NON-NLS-2$ // %NON-NLS-3$ (name.equals(parentPath) && parentPath.endsWith(":\\"))) //$NON-NLS-1$
) )
{ {
@ -316,13 +320,21 @@ public class DStoreHostFile implements IHostFile
protected static long getFileLength(String attributes) protected static long getFileLength(String attributes)
{ {
String str = getAttribute(attributes, ATTRIBUTE_SIZE); String str = getAttribute(attributes, ATTRIBUTE_SIZE);
return Long.parseLong(str); if (str != null && str.length() > 0)
{
return Long.parseLong(str);
}
return 0;
} }
protected static long getModifiedDate(String attributes) protected static long getModifiedDate(String attributes)
{ {
String str = getAttribute(attributes, ATTRIBUTE_MODIFIED_DATE); String str = getAttribute(attributes, ATTRIBUTE_MODIFIED_DATE);
return Long.parseLong(str); if (str != null && str.length() > 0)
{
return Long.parseLong(str);
}
return 0;
} }
protected static String getAttribute(String attributes, int index) protected static String getAttribute(String attributes, int index)
@ -386,20 +398,18 @@ public class DStoreHostFile implements IHostFile
public boolean canRead() { public boolean canRead() {
String str = getAttribute(_element.getSource(), ATTRIBUTE_CAN_READ); String str = getAttribute(_element.getSource(), ATTRIBUTE_CAN_READ);
if (str == null) if (str != null)
{
//System.out.println("HELP:"+_element.toString()); //$NON-NLS-1$
return false;
}
else
{ {
return(str.equals("true")); //$NON-NLS-1$ return(str.equals("true")); //$NON-NLS-1$
} }
return false;
} }
public boolean canWrite() { public boolean canWrite() {
String str = getAttribute(_element.getSource(), ATTRIBUTE_CAN_WRITE); String str = getAttribute(_element.getSource(), ATTRIBUTE_CAN_WRITE);
return(str.equals("true")); //$NON-NLS-1$ if (str != null)
return(str.equals("true")); //$NON-NLS-1$
return false;
} }
} }