Commit b89d5293 authored by Ben Avison's avatar Ben Avison
Browse files

Update from jwb - no longer appends ,xxx to filenames on server if the...

Update from jwb - no longer appends ,xxx to filenames on server if the filetype can already be determined from the file extension.

Version 2.27. Tagged as 'LanManFS-2_27'
parent 527b760b
/* (2.26) /* (2.27)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68. * Last processed by srccommit version: 1.2.
* *
*/ */
#define Module_MajorVersion_CMHG 2.26 #define Module_MajorVersion_CMHG 2.27
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 11 Mar 2003 #define Module_Date_CMHG 19 Dec 2003
#define Module_MajorVersion "2.26" #define Module_MajorVersion "2.27"
#define Module_Version 226 #define Module_Version 227
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "11 Mar 2003" #define Module_Date "19 Dec 2003"
#define Module_ApplicationDate "11-Mar-03" #define Module_ApplicationDate "19-Dec-03"
#define Module_ComponentName "LanManFS" #define Module_ComponentName "LanManFS"
#define Module_ComponentPath "RiscOS/Sources/Networking/Omni/Protocols/LanManFS" #define Module_ComponentPath "RiscOS/Sources/Networking/Omni/Protocols/LanManFS"
#define Module_FullVersion "2.26" #define Module_FullVersion "2.27"
#define Module_HelpVersion "2.26 (11 Mar 2003)" #define Module_HelpVersion "2.27 (19 Dec 2003)"
#define Module_LibraryVersionInfo "2:26" #define Module_LibraryVersionInfo "2:27"
...@@ -45,7 +45,8 @@ ...@@ -45,7 +45,8 @@
static char DOSnamebuf [NAMEBUF_LEN]; static char DOSnamebuf [NAMEBUF_LEN];
static err_t FileGetAttribs ( char *filename, DOS_ATTRIBS *pda,
RISCOS_ATTRIBS *pra );
#define name_R(x) ((char *)R[x]) #define name_R(x) ((char *)R[x])
...@@ -402,9 +403,24 @@ _kernel_oserror *fsentry_func ( int *R ) ...@@ -402,9 +403,24 @@ _kernel_oserror *fsentry_func ( int *R )
if ( err == OK ) if ( err == OK )
err = Xlt_ConvertPath( name_R(2), DOSnamebuf+DOS_NAME_LEN ); err = Xlt_ConvertPath( name_R(2), DOSnamebuf+DOS_NAME_LEN );
#ifdef LONGNAMES #ifdef LONGNAMES
if ( err == OK )
{ {
(void) Xlt_CnvRenameX2 ( DOSnamebuf, DOSnamebuf + DOS_NAME_LEN ); DOS_ATTRIBS da;
RISCOS_ATTRIBS ra;
err = FileGetAttribs ( DOSnamebuf, &da, &ra );
if ( err == EFILENOTFOUND || err == EPATHNOTFOUND )
{
err = OK;
}
if ( err == OK )
{
(void) Xlt_CnvRenameX2 ( DOSnamebuf, DOSnamebuf + DOS_NAME_LEN );
}
if (da.attr & ATTR_DIR) // force strip RO extent from dir name
{
Xlt_CnvRenameX2 ( DOSnamebuf+DOS_NAME_LEN,DOSnamebuf+DOS_NAME_LEN);
}
} }
#endif #endif
if ( err == OK ) if ( err == OK )
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "kernel.h" #include "kernel.h"
#include "stdtypes.h" #include "stdtypes.h"
#include "Global/FileTypes.h" #include "Global/FileTypes.h"
#include "swis.h"
#include "Xlate.h" #include "Xlate.h"
#include "attr.h" #include "attr.h"
...@@ -1296,12 +1297,22 @@ return res; ...@@ -1296,12 +1297,22 @@ return res;
* Note that the file saving routine actually uses this * Note that the file saving routine actually uses this
* routine to strip filetype information by passing both * routine to strip filetype information by passing both
* parameters the same. This must continue to function. * parameters the same. This must continue to function.
* JB 18/12/2003 .. make sure the ,xxx is only removed IF
* both names are NOT (identical and contains .xxx)
* (function only seen in file renaming so far JB)
*/ */
err_t Xlt_CnvRenameX2 ( char *src, char *dst ) err_t Xlt_CnvRenameX2 ( char *src, char *dst )
{ {
RISCOS_ATTRIBS RA; RISCOS_ATTRIBS RA;
char *terminator, *nterm; char *nterm; // *terminator
int cnvq=strcmp(src,dst); // check if just need to strip..
// if src and dst are same, check if it should have the ,xxx appended
// if so, ensure it still is...
if(!cnvq)
{
if((strlen(dst)>4) && (dst[strlen(dst)-4] == ',')) cnvq++;
}
if (Xlt_SplitLeafnameX2 ( dst, &RA, &nterm ) != OK) { if (Xlt_SplitLeafnameX2 ( dst, &RA, &nterm ) != OK) {
/* No type information - find end of string */ /* No type information - find end of string */
nterm = strchr(dst, '\0'); nterm = strchr(dst, '\0');
...@@ -1310,11 +1321,9 @@ err_t Xlt_CnvRenameX2 ( char *src, char *dst ) ...@@ -1310,11 +1321,9 @@ err_t Xlt_CnvRenameX2 ( char *src, char *dst )
/* Strip old type information in case source didn't have any either */ /* Strip old type information in case source didn't have any either */
*nterm = '\0'; *nterm = '\0';
} }
Xlt_SplitLeafnameX2 ( src, &RA, &nterm ) ; // recover source's filetype
if (Xlt_SplitLeafnameX2 ( src, &RA, &terminator ) == OK) { // if not identical strings.. add type if not in dos name
(void) strcpy(nterm, terminator); if (cnvq)Xlt_AddROType (dst,RA.loadaddr);
}
return OK; return OK;
} }
#endif #endif
...@@ -1323,13 +1332,14 @@ err_t Xlt_CnvRenameX2 ( char *src, char *dst ) ...@@ -1323,13 +1332,14 @@ err_t Xlt_CnvRenameX2 ( char *src, char *dst )
#ifdef LONGNAMES #ifdef LONGNAMES
/* Adds the type suffix for a RISC OS filename. The type is extracted /* Adds the type suffix for a RISC OS filename. The type is extracted
* from the passed load address. * from the passed load address. unless DOS name is sufficient
*/ */
int Xlt_AddROType ( char *leafname, uint loadaddr ) int Xlt_AddROType ( char *leafname, uint loadaddr )
{ {
RISCOS_ATTRIBS RA; RISCOS_ATTRIBS RA;
char *terminator; char *nterm, *term;
char typebuf[8]; char typebuf[8],ftypebuf[8];
int ftype;
typebuf[0] = FileChar_TypedNamePrefix; typebuf[0] = FileChar_TypedNamePrefix;
if (loadaddr == deaddead) { if (loadaddr == deaddead) {
...@@ -1343,15 +1353,37 @@ int Xlt_AddROType ( char *leafname, uint loadaddr ) ...@@ -1343,15 +1353,37 @@ int Xlt_AddROType ( char *leafname, uint loadaddr )
sprintf(typebuf+1, "%03x", type); sprintf(typebuf+1, "%03x", type);
} }
if (Xlt_SplitLeafnameX2 ( leafname, &RA, &terminator) == OK) { // strip any acorn filetype suffix
int extn_add_or_remove = (*terminator != *typebuf); if (Xlt_SplitLeafnameX2 ( leafname, &RA, &nterm ) != OK) {
strcpy(terminator, typebuf); /* No type information - find end of string */
return (RA.loadaddr >> 8) != (loadaddr >> 8) || (extn_add_or_remove); nterm = strchr(leafname, '\0');
} }
else { else {
strcat(leafname, typebuf); /* Strip old type information in case source didn't have any either */
return 1; *nterm = '\0';
}
// check leaf for dos file type, else add acorn extra...
if (leafname[1] == ':')
{
term = strrchr(leafname, '.'); /* strrchr catches names like "file.tar.gz" */
}
else
{
term = strrchr(leafname, '/'); /* strrchr catches names like "file/tar/gz" */
}
if(term)
{ // found a DOS type
if(!_swix(MimeMap_Translate,_INR(0,2)|_OUT(3), // so check the mimemap
MMM_TYPE_DOT_EXTN,term,
MMM_TYPE_RISCOS,&ftype))
{ // got a name valid in RISCOS
sprintf(ftypebuf,",%03x",ftype);
if(!strcmp(typebuf,ftypebuf)) return 1; // its OK.. no need to append type
}
} }
strcat(leafname, typebuf);
return 1;
} }
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment