예제 #1
0
 /// <summary>
 /// Resolves the link to the true path.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 /// <workitem id="19712">Uses "ls -l" to resolve links</workitem>
 public String ResolveLink(String path)
 {
     if (this.Device.BusyBox.Available)
     {
         var cresult = new CommandResultReceiver( );
         this.Device.BusyBox.ExecuteShellCommand("readlink -f {0}", cresult, path);
         // if cresult is empty, return the path
         return((cresult == null || String.IsNullOrEmpty(cresult.Result)) ? path : cresult.Result);
     }
     else
     {
         try {
             // this uses the ls command to get the link path
             var receiver = new LinkResoverReceiver( );
             Device.ExecuteShellCommand("ls {0} -l".With(path.ToArgumentSafe( )), receiver);
             if (!String.IsNullOrEmpty(receiver.ResolvedPath))
             {
                 return(receiver.ResolvedPath);
             }
         } catch (Exception e) {
             Log.d("FileSytem", e.Message);
         }
         return(path);
     }
 }
예제 #2
0
 /// <summary>
 /// Resolves the link to the true path.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 /// <workitem id="19712">Uses "ls -l" to resolve links</workitem>
 public String ResolveLink(String path)
 {
     if (this.Device.BusyBox.Available)
     {
         var cresult = new CommandResultReceiver( );
         this.Device.BusyBox.ExecuteShellCommand("readlink -f {0}", cresult, path);
         // if cresult is empty, return the path
         return((cresult == null || String.IsNullOrEmpty(cresult.Result)) ? path : cresult.Result);
     }
     else
     {
         try {
             // have to try 2 ways because why the hell would it just work...
             var cresult = new CommandResultReceiver( );
             this.Device.ExecuteShellCommand("readlink -f {0}", cresult, path);
             if (string.IsNullOrWhiteSpace(cresult.Result))
             {
                 cresult = new CommandResultReceiver( );
                 this.Device.ExecuteShellCommand("readlink {0}", cresult, path);
                 return((string.IsNullOrWhiteSpace(cresult.Result)) ? path : cresult.Result);
             }
             return(cresult.Result);
         } catch (Exception) {
             // if the command doesn't exist then we just return the path.
         }
         return(path);
     }
 }
예제 #3
0
 /// <summary>
 /// Resolves the link to the true path.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <returns></returns>
 /// <workitem id="19712">Uses "ls -l" to resolve links</workitem>
 public String ResolveLink( String path )
 {
     if ( this.Device.BusyBox.Available ) {
         var cresult = new CommandResultReceiver ( );
         this.Device.BusyBox.ExecuteShellCommand ( "readlink -f {0}", cresult, path );
         // if cresult is empty, return the path
         return ( cresult == null || String.IsNullOrEmpty ( cresult.Result ) ) ? path : cresult.Result;
     } else {
         try {
             // this uses the ls command to get the link path
             var receiver = new LinkResoverReceiver ( );
             Device.ExecuteShellCommand ( "ls {0} -l".With ( path.ToArgumentSafe ( ) ), receiver );
             if ( !String.IsNullOrEmpty ( receiver.ResolvedPath ) ) {
                 return receiver.ResolvedPath;
             }
         } catch ( Exception e ) {
             Log.d ( "FileSytem", e.Message );
         }
         return path;
     }
 }