765 @return tuple containing head and tail, where tail is everything after the last |
765 @return tuple containing head and tail, where tail is everything after the last |
766 path separator. |
766 path separator. |
767 @rtype tuple of (str, str) |
767 @rtype tuple of (str, str) |
768 """ |
768 """ |
769 if self.__serverInterface.isServerConnected(): |
769 if self.__serverInterface.isServerConnected(): |
770 i = p.rfind(self.__serverPathSep) + 1 |
770 if self.__serverPathSep == "\\": |
771 head, tail = p[:i], p[i:] |
771 # remote is a Windows system |
|
772 normp = p.replace("/", "\\") |
|
773 else: |
|
774 # remote is a Posix system |
|
775 normp = p.replace("\\", "/") |
|
776 |
|
777 i = normp.rfind(self.__serverPathSep) + 1 |
|
778 head, tail = normp[:i], normp[i:] |
772 if head and head != self.__serverPathSep * len(head): |
779 if head and head != self.__serverPathSep * len(head): |
773 head = head.rstrip(self.__serverPathSep) |
780 head = head.rstrip(self.__serverPathSep) |
774 return head, tail |
781 return head, tail |
775 |
782 |
776 else: |
783 else: |
784 @type str |
791 @type str |
785 @return tuple containing the root part and the extension |
792 @return tuple containing the root part and the extension |
786 @rtype tuple of (str, str) |
793 @rtype tuple of (str, str) |
787 """ |
794 """ |
788 return os.path.splitext(p) |
795 return os.path.splitext(p) |
|
796 |
|
797 def splitdrive(self, p): |
|
798 """ |
|
799 Public method to split a path into drive and path. |
|
800 |
|
801 @param p path name to be split |
|
802 @type str |
|
803 @return tuple containing the drive letter (incl. colon) and the path |
|
804 @rtype tuple of (str, str) |
|
805 """ |
|
806 if self.__serverInterface.isServerConnected(): |
|
807 plainp = FileSystemUtilities.plainFileName(p) |
|
808 |
|
809 if self.__serverPathSep == "\\": |
|
810 # remote is a Windows system |
|
811 normp = plainp.replace("/", "\\") |
|
812 if normp[1:2] == ":": |
|
813 return normp[:2], normp[2:] |
|
814 else: |
|
815 return "", normp |
|
816 else: |
|
817 # remote is a Posix system |
|
818 normp = plainp.replace("\\", "/") |
|
819 return "", normp |
|
820 |
|
821 else: |
|
822 return os.path.splitdrive(p) |
789 |
823 |
790 def dirname(self, p): |
824 def dirname(self, p): |
791 """ |
825 """ |
792 Public method to extract the directory component of a path name. |
826 Public method to extract the directory component of a path name. |
793 |
827 |