It is currently Sat Dec 05, 2020 12:50 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: CheckFilename1(name.s,ParentDirectory.s="")
PostPosted: Mon Apr 20, 2020 3:49 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Jan 22, 2009 3:48 am
Posts: 640
Location: china
Code:
Global Dim nm.s(11)
nm(n)="/":n+1
nm(n)="\":n+1
nm(n)=":":n+1
nm(n)=~"\"":n+1
nm(n)="?":n+1
nm(n)="*":n+1
nm(n)="|":n+1
nm(n)="<":n+1
nm(n)=">":n+1
nm(n)=Chr(9):n+1
nm(n)=Chr(10):n+1
nm(n)=Chr(13)

Procedure.s  CheckFilename1(name.s,ParentDirectory.s="");("a.ini","c:\")
 ;TODO note:
 name=Trim(name,".")
 nameLen=Len(name)
 c=Len(ParentDirectory)+nameLen
 If c>258
  ;#MAX_PATH=260,but need 'c:\'+{255}=258
  d=c-258
  MessageRequester("","too long ! please cut "+d+" character")
  ProcedureReturn "";TODO no
 EndIf
 If nameLen
  ;-{for winxp,see pb help CheckFilename()
  If nameLen=3
   l3.s{3}=UCase(name)
   If l3="AUX" Or l3="CON" Or l3="PRN" Or l3="NUL"
    MessageRequester("","name cannot is '"+name+"'")
    ProcedureReturn "";TODO no
   EndIf
  ElseIf nameLen=4
   l3=UCase(Left(name,3)):r1.s{1}=Right(name,1)
   If (l3="COM" Or l3="LPT") And r1<":" And r1>"/";0-9
    MessageRequester("","name cannot is '"+name+"' [Case insensitive]")
    ProcedureReturn "";TODO no
   EndIf
  EndIf
  ;}
  For t=1 To nameLen
   s1.s{1}=Mid(name,t,1)
   For a=0 To 11
    If s1=nm(a)
     MessageRequester("","please not use '"+s1+"'")
     ProcedureReturn "";TODO no
    EndIf
   Next
  Next
 Else
  MessageRequester("","name is blank !")
  ProcedureReturn "";TODO no
 EndIf
 ProcedureReturn name;TODO ok only here
EndProcedure
Debug CheckFilename1("ddd")
Debug CheckFilename1("/ytt")
Debug CheckFilename1(".")
Debug CheckFilename1("aux")
Debug CheckFilename1("COM6")
Debug CheckFilename1("LPt0")
Debug CheckFilename1(Chr(9))
Debug CheckFilename1(Chr(10))
Debug CheckFilename1(Chr(13))
Debug CheckFilename(Chr(9))
Debug CheckFilename(Chr(10))
Debug CheckFilename(Chr(13))

; IDE Options = PureBasic 5.72 (Windows - x86)
; CursorPosition = 67
; FirstLine = 49
; Folding = --
; DPIAware
; DisableDebugger

_________________
my pb for chinese:
http://ataorj.ys168.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye