455 | | {_T("HASH"), {commands::HASH, true, false}} |
| 460 | {_T("HASH"), {commands::HASH, true, false}}, |
| 461 | {_T("CPFR"), {commands::CPFR, true, false}}, |
| 462 | {_T("CPTO"), {commands::CPTO, true, false}} |
| 1945 | case commands::CPFR: |
| 1946 | { |
| 1947 | //Unquote args |
| 1948 | if (!UnquoteArgs(args)) { |
| 1949 | Send( _T("501 Syntax error") ); |
| 1950 | break; |
| 1951 | } |
| 1952 | |
| 1953 | CopyName = _T(""); |
| 1954 | |
| 1955 | CStdString physicalFile, logicalFile; |
| 1956 | int error = m_owner.m_pPermissions->CheckFilePermissions(m_status.user, args, m_CurrentServerDir, FOP_READ, physicalFile, logicalFile); |
| 1957 | if (!error) { |
| 1958 | CopyName = physicalFile; |
| 1959 | Send(_T("350 File exists, ready for destination name.")); |
| 1960 | break; |
| 1961 | } |
| 1962 | else if (error & PERMISSION_DENIED) |
| 1963 | Send(_T("550 Permission denied")); |
| 1964 | else if (error & PERMISSION_INVALIDNAME) |
| 1965 | Send(_T("550 Filename invalid.")); |
| 1966 | else if (error & PERMISSION_NOTFOUND) |
| 1967 | Send(_T("550 file not found")); |
| 1968 | else { |
| 1969 | Send(_T("553 Copy of directory not supported.")); |
| 1970 | break; |
| 1971 | } |
| 1972 | } |
| 1973 | break; |
| 1974 | case commands::CPTO: |
| 1975 | { |
| 1976 | if (CopyName == _T("")) |
| 1977 | { |
| 1978 | Send(_T("503 Bad sequence of commands!")); |
| 1979 | break; |
| 1980 | } |
| 1981 | |
| 1982 | //Unquote args |
| 1983 | if (!UnquoteArgs(args)) { |
| 1984 | Send( _T("501 Syntax error") ); |
| 1985 | break; |
| 1986 | } |
| 1987 | |
| 1988 | CStdString physicalFile, logicalFile; |
| 1989 | int error = m_owner.m_pPermissions->CheckFilePermissions(m_status.user, args, m_CurrentServerDir, FOP_CREATENEW, physicalFile, logicalFile); |
| 1990 | if (error) |
| 1991 | CopyName = _T(""); |
| 1992 | if (error & PERMISSION_DENIED) |
| 1993 | Send(_T("550 Permission denied")); |
| 1994 | else if (error & PERMISSION_INVALIDNAME) |
| 1995 | Send(_T("553 Filename invalid")); |
| 1996 | else if (error & PERMISSION_DOESALREADYEXIST && (error & PERMISSION_DIRNOTFILE)!=PERMISSION_DIRNOTFILE) |
| 1997 | Send(_T("553 File exists")); |
| 1998 | else if (error) |
| 1999 | Send(_T("553 Filename invalid")); |
| 2000 | else |
| 2001 | { |
| 2002 | Send(_T("151 Copying the file")); |
| 2003 | if (!CopyFile(RenName, physicalFile, TRUE)) |
| 2004 | Send(_T("450 Internal error copying the file")); |
| 2005 | else |
| 2006 | Send(_T("250 file copied successfully")); |
| 2007 | } |
| 2008 | } |
| 2009 | break; |