Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Fix the "mv" command so that it will move directories. Patch from Dingyuan Wang. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
0a34967beb57cfa1f86d8e1657930774 |
| User & Date: | drh 2018-05-29 14:23:47 |
Context
|
2018-05-30
| ||
| 01:28 | Update the build-in SQLite to the first 3.24.0 beta. check-in: bbdfec3f31 user: drh tags: trunk | |
|
2018-05-29
| ||
| 14:23 | Fix the "mv" command so that it will move directories. Patch from Dingyuan Wang. check-in: 0a34967beb user: drh tags: trunk | |
|
2018-05-21
| ||
| 01:01 | Fix harmless compiler warning. check-in: a7056e6499 user: mistachkin tags: trunk | |
Changes
Changes to src/add.c.
| ︙ | ︙ | |||
857 858 859 860 861 862 863 864 865 866 867 868 869 870 |
void mv_cmd(void){
int i;
int vid;
int moveFiles;
int dryRunFlag;
int softFlag;
int hardFlag;
char *zDest;
Blob dest;
Stmt q;
db_must_be_within_tree();
dryRunFlag = find_option("dry-run","n",0)!=0;
softFlag = find_option("soft",0,0)!=0;
| > > | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 |
void mv_cmd(void){
int i;
int vid;
int moveFiles;
int dryRunFlag;
int softFlag;
int hardFlag;
int origType;
int destType;
char *zDest;
Blob dest;
Stmt q;
db_must_be_within_tree();
dryRunFlag = find_option("dry-run","n",0)!=0;
softFlag = find_option("soft",0,0)!=0;
|
| ︙ | ︙ | |||
898 899 900 901 902 903 904 |
file_tree_name(zDest, &dest, 0, 1);
db_multi_exec(
"UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
);
db_multi_exec(
"CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);"
);
| < < | > > | | > > > > > > > > | 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 |
file_tree_name(zDest, &dest, 0, 1);
db_multi_exec(
"UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
);
db_multi_exec(
"CREATE TEMP TABLE mv(f TEXT UNIQUE ON CONFLICT IGNORE, t TEXT);"
);
if( g.argc!=4 ){
origType = -1;
}else{
origType = (file_isdir(g.argv[2], RepoFILE) == 1);
}
destType = file_isdir(zDest, RepoFILE);
if( origType==-1 && destType!=1 ){
usage("OLDNAME NEWNAME");
}else if( origType==1 && destType==2 ){
fossil_fatal("cannot rename '%s' to '%s' since another file named"
" '%s' exists", g.argv[2], zDest, zDest);
}else if( origType==0 && destType!=1 ){
Blob orig;
file_tree_name(g.argv[2], &orig, 0, 1);
db_multi_exec(
"INSERT INTO mv VALUES(%B,%B)", &orig, &dest
);
}else{
if( blob_eq(&dest, ".") ){
blob_reset(&dest);
|
| ︙ | ︙ | |||
934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
);
while( db_step(&q)==SQLITE_ROW ){
const char *zPath = db_column_text(&q, 0);
int nPath = db_column_bytes(&q, 0);
const char *zTail;
if( nPath==nOrig ){
zTail = file_tail(zPath);
}else{
zTail = &zPath[nOrig+1];
}
db_multi_exec(
"INSERT INTO mv VALUES('%q','%q%q')",
zPath, blob_str(&dest), zTail
);
| > > | 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
);
while( db_step(&q)==SQLITE_ROW ){
const char *zPath = db_column_text(&q, 0);
int nPath = db_column_bytes(&q, 0);
const char *zTail;
if( nPath==nOrig ){
zTail = file_tail(zPath);
}else if( destType==1 ){
zTail = &zPath[nOrig-strlen(file_tail(zOrig))];
}else{
zTail = &zPath[nOrig+1];
}
db_multi_exec(
"INSERT INTO mv VALUES('%q','%q%q')",
zPath, blob_str(&dest), zTail
);
|
| ︙ | ︙ |